Beispiel #1
0
 protected virtual void SendMessage(PeerState peer, PeerMessage message)
 {
     if (Stopping)
     {
         return;
     }
     MessageIO.SendMessage(peer.Socket, message, peer, MessageSent);
 }
Beispiel #2
0
 protected virtual void ReceiveMessage(PeerState peer)
 {
     if (Stopping)
     {
         return;
     }
     MessageIO.ReceiveMessage(peer.Socket, peer, MessageReceived);
 }
Beispiel #3
0
 protected virtual void SendHandshake(PeerState peer, HandshakeMessage handshake)
 {
     if (Stopping)
     {
         return;
     }
     MessageIO.SendMessage(peer.Socket, handshake, peer, HandshakeSent);
 }
Beispiel #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);
     }
 }