Ejemplo n.º 1
0
 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.");
     }
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="client"></param>
 public void OnClientConnected(SocketClient client)
 {
     Console.Out.WriteLine("Client connected!");
     clients.AddLast(new ChatClientListener(client));
 }
Ejemplo n.º 4
0
 public void OnClientConnected(SocketClient client)
 {
     clients.AddLast(new GameClientListener(client));
     client.SocketName = "Client nr " + clients.Count;
 }