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