private static void ServerConnection_OnAccept(object self) { Energy.Core.Network.SocketClient clientConnection = self as Energy.Core.Network.SocketClient; string text = string.Format(Global.HelloText, Global.ClientCounter.Increment()); clientConnection.Send(System.Text.Encoding.UTF8.GetBytes(text)); }
private static void ServerConnection_OnReceive(object self, byte[] data) { Energy.Core.Network.SocketClient clientConnection = self as Energy.Core.Network.SocketClient; string text = Encoding.UTF8.GetString(data); Console.WriteLine("Client message from " + clientConnection.ToString() + ": " + text); clientConnection.Send(System.Text.Encoding.UTF8.GetBytes(text)); }
private static void Connection_OnConnect(object self) { Energy.Core.Network.SocketClient connection = self as Energy.Core.Network.SocketClient; if (connection == null) { string tilde = "~r~ERROR~0~ ~lm~Object is null in ~y~Connection_OnConnect"; Energy.Core.Tilde.WriteLine(tilde); return; } int size = 10000; if (!connection.Send(new string('A', size) + "\r\n")) { Energy.Core.Tilde.WriteLine("~r~ERROR~0~ ~lm~Send error in ~y~Connection_OnConnect"); } if (!connection.Send(new string('B', size) + "\r\n")) { Energy.Core.Tilde.WriteLine("~r~ERROR~0~ ~lm~Send error in ~y~Connection_OnConnect"); } if (!connection.Send(new string('C', size) + "\r\n")) { Energy.Core.Tilde.WriteLine("~r~ERROR~0~ ~lm~Send error in ~y~Connection_OnConnect"); } if (!connection.Send(new string('D', size) + "\r\n")) { Energy.Core.Tilde.WriteLine("~r~ERROR~0~ ~lm~Send error in ~y~Connection_OnConnect"); } if (!connection.Receive()) { Energy.Core.Tilde.WriteLine("~r~ERROR~0~ ~lm~Receive error in ~y~Connection_OnConnect"); } else { Energy.Core.Tilde.WriteLine("~r~OK~0~ ~lc~Start receiving in ~y~Connection_OnConnect"); } if (!connection.Send(new string('A', size) + "\r\n")) { Energy.Core.Tilde.WriteLine("~r~ERROR~0~ ~lm~Send error in ~y~Connection_OnConnect"); } if (!connection.Send(new string('B', size) + "\r\n")) { Energy.Core.Tilde.WriteLine("~r~ERROR~0~ ~lm~Send error in ~y~Connection_OnConnect"); } if (!connection.Send(new string('C', size) + "\r\n")) { Energy.Core.Tilde.WriteLine("~r~ERROR~0~ ~lm~Send error in ~y~Connection_OnConnect"); } if (!connection.Send(new string('D', size) + "\r\n")) { Energy.Core.Tilde.WriteLine("~r~ERROR~0~ ~lm~Send error in ~y~Connection_OnConnect"); } }