Beispiel #1
0
 public void Broadcast(Peer[] peers, BroadcastType broadcastType, Dictionary<byte, object> parameter)
 {
     EventData eventData = new EventData((byte)broadcastType, parameter);
     foreach (Peer peer in peers)
     {
         peer.SendEvent(eventData);
     }
 }
 void AcceptConnection()
 {
     serverListener.Start();
     server.logger.Info("Waiting for connection ....");
     while (!isTerminated)
     {
         TcpClient client = serverListener.AcceptTcpClient();
         server.logger.Info(string.Format("Accept connectiion from {0} : {1}", (client.Client.RemoteEndPoint as IPEndPoint).Address, (client.Client.RemoteEndPoint as IPEndPoint).Port));
         Guid newGuid = Guid.NewGuid();
         Peer peer = new Peer(newGuid, client, server);
         peer.OnPeerDisconnect += PeerDisconnect;
         peerDictionary.Add(newGuid, peer);
         Thread.Sleep(1);
     }
 }
 public ServerUser(string userName, bool ready, Peer peer)
     : base(userName, ready)
 {
     Peer = peer;
 }