4 define ECOMMUNICATOR_PORT = 3113;
8 define app = (eComApp) __thisModule;
10 class ConnectionSocket;
14 class MainPanel : Window
16 eComService service { mainPanel = this };
19 background = activeBorder, tabCycle = true;
20 borderStyle = sizable, hasClose = true, hasMinimize = true, text = app.appName, size = Size { 500, 320 }, minClientSize = Size { 320, 200 };
24 this, isDefault = true, text = "Connect", position = Point { 220, 30 }, size = Size { 80, 0 }, hotKey = altC;
26 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
28 ConnectionSocket { mainPanel = this }.Connect(address.contents, service.port);
34 this, text = "Host", position = Point { 220, 60 }, size = Size { 80, 0 }, hotKey = altH;
36 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
41 log.Printf("\nHosting on port %d", service.port);
43 stopHosting.disabled = false;
50 this, text = "Local Host", position = Point { 320, 30 }, size = Size { 80, 0 }, hotKey = altL;
52 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
54 char hostName[256], address[64];
55 GetHostName(hostName, sizeof(hostName));
56 GetAddressFromName(hostName, address);
58 log.Printf("\nLocal Host: %s => %s", hostName, address);
64 this, text = "Stop", position = Point { 320, 60 }, size = Size { 80, 0 }, hotKey = altS;
66 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
69 stopHosting.disabled = true;
70 host.disabled = false;
77 this, readOnly = true, multiLine = true, autoEmpty = true, hasVertScroll = true, hasHorzScroll = true, inactive = true,
78 text = "Communication Log",
79 anchor = Anchor { left = 10, top = 100, right = 10, bottom = 30 },
80 contents = app.appName
84 this, position = Point { 10, 80 }, labeledWindow = log
88 this, text = "Name", position = Point { 50, 55 }, size = Size { 160,20 };
90 void NotifyUpdate(EditBox editBox)
92 char * string = nameBox.contents;
94 for(link = connections.first; link; link = link.next)
95 ((Connection)link.data).SendName(string);
100 this, position = Point { 10, 55 }, labeledWindow = nameBox
105 this, text = "Clear", anchor = Anchor { left = 10, bottom = 5 }, size = Size { 80, 0 }, hotKey = altR;
107 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
115 this, text = "Exit", size = Size { 80, 0 }, anchor = Anchor { right = 10, bottom = 5 }, hotKey = altX;
117 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
126 this, contents = "localhost", hasHorzScroll = true, text = "Internet Address", position = Point { 10, 30 }, size = Size { 200,20 }, hotKey = altA;
128 void NotifyUpdate(EditBox editBox)
130 connect.disabled = address.contents[0] ? false : true;
135 this, position = Point { 10, 10 }, labeledWindow = address
138 void ConnectionDestroyed(Connection connection)
141 log.Printf("\n%s disconnected", connection.text);
142 connections.Delete(connections.FindLink(connection));
145 void OnConnect(Connection connection, char * inetAddress, char * address)
148 log.Printf("\nConnected to %s (%s)", inetAddress, address);
149 connection.SendName(nameBox.contents);
150 connections.Add(OldLink{data = connection});
154 MainPanel mainPanel {};
156 class eComApp : GuiApplication
158 appName = "ECERE Communicator (Build 0002.5)";
161 class eComService : Service
165 port = ECOMMUNICATOR_PORT;
169 char address[256] = "";
170 Connection connection;
172 ConnectionSocket socket { this, mainPanel = mainPanel };
174 GetNameFromAddress(socket.inetAddress, address);
176 mainPanel.log.Printf("\nConnection accepted from %s (%s)", socket.inetAddress, address);
178 socket.connection = connection = Connection { text = "Incoming Connection...", socket = socket, master = mainPanel };
179 mainPanel.connections.Add(OldLink{data = connection});
182 connection.SendName(mainPanel.nameBox.contents);
185 property MainPanel mainPanel { set { mainPanel = value; } }