File: main.ec

package info (click to toggle)
ecere-sdk 0.44.15-1
  • links: PTS
  • area: main
  • in suites: sid, stretch
  • size: 97,712 kB
  • ctags: 54,695
  • sloc: ansic: 593,042; makefile: 12,250; yacc: 4,955; lex: 707; objc: 259; python: 252; xml: 102
file content (83 lines) | stat: -rw-r--r-- 2,272 bytes parent folder | download | duplicates (2)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import "ecere"

import remote "Server"

ChatConnection connection;

class Form1 : Window
{
   caption = $"Server";
   background = formColor;
   borderStyle = sizable;
   minClientSize = { 340, 200 };
   hasMaximize = true;
   hasMinimize = true;
   hasClose = true;
   clientSize = { 640, 460 };
   tabCycle = true;

   EditBox log { this, anchor = { left = 16, top = 56, right = 18, bottom = 81 }, multiLine = true };
   EditBox serverAddress { this, size = { 182, 27 }, anchor = { top = 16, right = 82 }, contents = "localhost" };
   Button btnConnect
   {
      this, caption = $"Connect", anchor = { top = 24, right = 20 }, hotKey = altC;

      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {
         connection = ChatConnection
         {
            void NotifyMessage(const String msg)
            {
               form1.log.PutS(" < ");
               form1.log.PutS(msg);
               form1.log.PutS("\n");
            }

            void OnDisconnect(int code)
            {
               DCOMClientObject::OnDisconnect(code);
               if(form1)
                  form1.btnSend.disabled = true;
            }
         };
         if(connection.Connect(serverAddress.contents, 1494))
         {
            connection.Join();
            btnSend.disabled = false;
         }
         return true;
      }
   };
   Button btnHost
   {
      this, caption = $"Host", position = { 32, 16 }, hotKey = altH;

      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {
         chatService.Start();
         return true;
      }
   };
   EditBox message { this, size = { 526, 43 }, anchor = { left = 16, right = 98, bottom = 17 } };
   Button btnSend
   {
      this, caption = $"Send", isDefault = true, size = { 60, 37 }, anchor = { right = 20, bottom = 23 }, disabled = true;

      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {
         if(serverConnection)
            SendBackMessage(message.contents);
         else
            connection.SendMessage(message.contents);
         log.PutS(" > ");
         log.PutS(message.contents);
         log.PutS("\n");
         message.Clear();
         return true;
      }
   };
}

Form1 form1 {};

DCOMService chatService { port = 1494 };