protected virtual void SendMessage(PeerState peer, PeerMessage message) { if (Stopping) { return; } MessageIO.SendMessage(peer.Socket, message, peer, MessageSent); }
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); }
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); } }