Ejemplo n.º 1
0
 public NetworkConnection(int clientId, NetworkMessageReceiver networkMessageReceiver, NetworkMessageWriter networkMessageWriter)
 {
     ClientId = clientId;
     _networkMessageReceiver = networkMessageReceiver;
     _networkMessageWriter   = networkMessageWriter;
     _networkMessageReceiver.MessageRecieved += ElevateMessageEvent;
     _isReceiving    = true;
     _receiverThread = new Thread(GetMessages);
     _receiverThread.Start();
 }
        private NetworkConnection CreateNetworkClient(Socket handler)
        {
            var clientId = NEXT_CLIENT_ID++;
            NetworkMessageReceiver networkMessageReceiver = new NetworkMessageReceiver(clientId, handler, 1024);
            NetworkMessageWriter   networkMessageWriter   = new NetworkMessageWriter(handler);
            NetworkConnection      networkConnection      = new NetworkConnection(clientId, networkMessageReceiver, networkMessageWriter);

            networkConnection.MessageRecieved += RebroadcastMessage;
            return(networkConnection);
        }