cleaned all trailing white space from source files.
[sdk] / samples / net / DCOMSample / main.ec
1 import "ecere"
2
3 import remote "Server"
4
5 ChatConnection connection;
6
7 class Form1 : Window
8 {
9    text = "Server";
10    background = activeBorder;
11    borderStyle = sizable;
12    hasMaximize = true;
13    hasMinimize = true;
14    hasClose = true;
15    size = { 640, 480 };
16
17    EditBox log { this, size = { 598, 323 }, position = { 16, 56 }, multiLine = true };
18    EditBox serverAddress { this, contents = "localhost", size = { 182, 27 }, position = { 360, 16 } };
19    Button btnConnect
20    {
21       this, text = "Connect", position = { 560, 24 };
22
23       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
24       {
25          connection = ChatConnection
26          {
27             void NotifyMessage(String msg)
28             {
29                form1.log.PutS(" < ");
30                form1.log.PutS(msg);
31                form1.log.PutS("\n");
32             }
33
34             void OnDisconnect(int code)
35             {
36                DCOMClientObject::OnDisconnect(code);
37                if(form1)
38                   form1.btnSend.disabled = true;
39             }
40          };
41          if(connection.Connect(serverAddress.contents, 1494))
42          {
43             connection.Join();
44             btnSend.disabled = false;
45          }
46          return true;
47       }
48    };
49    Button btnHost
50    {
51       this, text = "Host", position = { 32, 16 };
52
53       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
54       {
55          chatService.Start();
56          return true;
57       }
58    };
59    EditBox message { this, size = { 510, 43 }, position = { 16, 400 } };
60    Button btnSend
61    {
62       this, text = "Send", isDefault = true, size = { 60, 37 }, position = { 552, 400 };
63       disabled = true;
64
65       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
66       {
67          if(serverConnection)
68             SendBackMessage(message.contents);
69          else
70             connection.SendMessage(message.contents);
71          log.PutS(" > ");
72          log.PutS(message.contents);
73          log.PutS("\n");
74          message.Clear();
75          return true;
76       }
77    };
78 }
79
80 Form1 form1 {};
81
82 DCOMService chatService { port = 1494 };