예제 #1
0
        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);
        }
예제 #2
0
        protected virtual void OnReceive(MalockSocketStream e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }
            EventHandler <MalockSocketStream> evt = this.Received;

            if (evt != null)
            {
                evt(this, e);
            }
        }
예제 #3
0
        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));
            }
        }
예제 #4
0
 protected override bool TryDeserializeMessage(MalockSocketStream stream, out MSG message)
 {
     return(MSG.TryDeserialize(stream.Stream, out message));
 }