예제 #1
0
 protected virtual void ReceiveMessage(PeerState peer)
 {
     if (Stopping)
     {
         return;
     }
     MessageIo.ReceiveMessage(peer.Socket, peer, MessageReceived);
 }
예제 #2
0
 protected virtual void SendHandshake(PeerState peer, HandshakeMessage handshake)
 {
     if (Stopping)
     {
         return;
     }
     MessageIo.SendMessage(peer.Socket, handshake, peer, HandshakeSent);
 }
예제 #3
0
 protected virtual void SendMessage(PeerState peer, PeerMessage message)
 {
     if (Stopping)
     {
         return;
     }
     MessageIo.SendMessage(peer.Socket, message, peer, MessageSent);
 }
예제 #4
0
 private static void EndAccept(IAsyncResult ar)
 {
     try
     {
         var socket    = (Socket)ar.AsyncState;
         var newsocket = (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);
     }
 }