lace_0.1.0_347e4627/applet/demo/event/distributed/launch_simple_chat_client.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
with
     chat.Client.local,

     lace.Event.utility,

     ada.Characters.latin_1,
     ada.command_Line,
     ada.Text_IO,
     ada.Exceptions;

procedure launch_simple_chat_Client
--
-- Starts a chat client.
--
is
   use ada.Text_IO;
begin
   -- Usage
   --
   if ada.command_Line.argument_Count /= 1
   then
      put_Line ("Usage:   $ ./launch_simple_chat_Client  <nickname>");
      return;
   end if;

   declare
      use chat.Client.local;

      client_Name : constant String        := ada.command_Line.Argument (1);
      the_Client  : chat.Client.local.item := to_Client (client_Name);
   begin
      the_Client.start;
   end;

exception
   when E : others =>
      lace.Event.utility.close;

      new_Line;
      put_Line ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
      put_Line ("Unhandled exception, aborting. Please report the following to developer.");
      put_Line ("________________________________________________________________________");
      put_Line (ada.Exceptions.exception_Information (E));
      put (ada.Characters.latin_1.ESC & "[1A");   -- Move cursor up.
      put_Line ("________________________________________________________________________");
      new_Line;
end launch_simple_chat_Client;