Exemplo n.º 1
0
 protected virtual void SendMessage(PeerState peer, PeerMessage message)
 {
     if (Stopping)
     {
         return;
     }
     MessageIO.SendMessage(peer.Socket, message, peer, MessageSent);
 }
Exemplo n.º 2
0
 protected virtual void ReceiveMessage(PeerState peer)
 {
     if (Stopping)
     {
         return;
     }
     MessageIO.ReceiveMessage(peer.Socket, peer, MessageReceived);
 }
Exemplo n.º 3
0
 protected virtual void SendHandshake(PeerState peer, HandshakeMessage handshake)
 {
     if (Stopping)
     {
         return;
     }
     MessageIO.SendMessage(peer.Socket, handshake, peer, HandshakeSent);
 }
Exemplo n.º 4
0
 private static void EndAccept(IAsyncResult ar)
 {
     try
     {
         var    socket    = (Socket)ar.AsyncState;
         Socket newsocket = socket.EndAccept(ar);
         var    peer      = new PeerState(newsocket, (IPEndPoint)newsocket.RemoteEndPoint);
         MessageIO.ReceiveHandshake(newsocket, peer, HandshakeReceived);
         BeginListening();
     }
     catch (Exception e)
     {
         RaiseException(e);
     }
 }