protected virtual bool TryDeserializeMessage(MalockSocketStream stream, out TMessage message) { MSG msg; if (!MSG.TryDeserialize(stream.Stream, out msg)) { message = default(TMessage); return(false); } message = (TMessage)(object)msg; return(true); }
protected virtual void OnReceive(MalockSocketStream e) { if (e == null) { throw new ArgumentNullException("e"); } EventHandler <MalockSocketStream> evt = this.Received; if (evt != null) { evt(this, e); } }
protected virtual void SocketReceived(object sender, MalockSocketStream e) { TMessage message = default(TMessage); if (!this.TryDeserializeMessage(e, out message)) { MalockSocket socket = e.Socket; socket.Abort(); } else if (message != null) { this.OnMessage(new MalockNetworkMessage <TMessage>(this, e.Socket, e.Stream, message)); } }
protected override bool TryDeserializeMessage(MalockSocketStream stream, out MSG message) { return(MSG.TryDeserialize(stream.Stream, out message)); }