public void Enable() { Sock.Listen(100); while (!Closing) { Socket Connection; try { Connection = Sock.Accept(); } catch (Exception ex) { Show("Unable to create a new connection with a newly created connection."); Show(ex); Sock.Close(); return; } if (Connection.Connected) { if (onClientConnectedListeners != null) { SocketClient sock = new SocketClient(Connection, SocketName); new Thread(sock.Enable).Start(); onClientConnectedListeners(sock); } } else Show("The Connection wasn't connected. Weird o_o."); } }
public ChatClientListener(SocketClient client) { this.client = client; // Wait for it ... while (client.packetProcessor == null) { Console.Out.WriteLine("Waiting for instance.."); Thread.Sleep(1); } client.packetProcessor.onProcessPacket += this.OnPacketReceived; this.client.onDisconnectListeners += this.OnDisconnect; this.client.onPacketSendListeners += this.OnPacketSend; }
/// <summary> /// /// </summary> /// <param name="client"></param> public void OnClientConnected(SocketClient client) { Console.Out.WriteLine("Client connected!"); clients.AddLast(new ChatClientListener(client)); }
public void OnClientConnected(SocketClient client) { clients.AddLast(new GameClientListener(client)); client.SocketName = "Client nr " + clients.Count; }