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