Пример #1
0
    private MessageHandler EndReadOneMessage(IAsyncResult iasyncResult_0)
    {
        Class7 asyncState = (Class7)iasyncResult_0.AsyncState;
        int    offset     = asyncState.GetStream().EndRead(iasyncResult_0);

        if (offset <= 0)
        {
            base.OnSomeOneDisconnected(asyncState, DisconnectedType.NetworkInterrupted);
            return(null);
        }
        int num2 = this.interface46_0.imethod_9();
        int size = num2 - offset;

        NetworkHelper.ReceiveData(asyncState.GetStream(), asyncState.method_4(), offset, size);
        base.method_2(asyncState, asyncState.method_4());
        Interface22 interface2 = this.interface46_0.imethod_10(asyncState.method_4(), 0);

        if (((interface2 == null) || (interface2.imethod_2() != this.interface46_0.imethod_8())) || ((num2 + interface2.imethod_5()) > base.imethod_9()))
        {
            MessageInvalidType invalidHeader = MessageInvalidType.InvalidHeader;
            if (interface2 != null)
            {
                invalidHeader = (interface2.imethod_2() == this.interface46_0.imethod_8()) ? MessageInvalidType.MessageSizeOverflow : MessageInvalidType.InvalidToken;
            }
            base.OnSomeOneDisconnected(asyncState, DisconnectedType.InvalidMessage);
            base.emptyAgileLogger_0.Log("ErrorMessage", string.Format("Source Address:{0} ,MessageInvalidType:{1}", asyncState.GetIPEndPoint(), invalidHeader), "CJFramework.Engine.Tcp.Server.StreamTcpEngine.EndReadOneMessage", ErrorLevel.Standard);
            base.OnInvalidMessageReceived(asyncState.GetIPEndPoint(), invalidHeader);
            return(null);
        }
        byte[] buffer = null;
        if (interface2.imethod_5() > 0)
        {
            if (interface2.imethod_5() > base.imethod_9())
            {
                string msg = string.Format("MessageBodyLength [{0}] exceed the MaxMessageSize! Source address : {1}.", interface2.imethod_5(), asyncState.GetIPEndPoint());
                base.emptyAgileLogger_0.Log("MessageSizeOverflow", msg, "CJFramework.Tcp.Server.StreamTcpEngine.EndReadOneMessage", ErrorLevel.Standard);
                base.OnSomeOneDisconnected(asyncState, DisconnectedType.InvalidMessage);
                return(null);
            }
            buffer = NetworkHelper.ReceiveData(asyncState.GetStream(), interface2.imethod_5());
        }
        return(new MessageHandler(interface2, buffer, 0, asyncState.GetIPEndPoint()));
    }