Exemplo n.º 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()));
    }
Exemplo n.º 2
0
    protected override void ServeOverLap(IAsyncResult iasyncResult_0)
    {
        Class7 asyncState = (Class7)iasyncResult_0.AsyncState;

        if (!asyncState.imethod_6())
        {
            try
            {
                MessageHandler class3 = this.EndReadOneMessage(iasyncResult_0);
                if (class3 != null)
                {
                    if (base.imethod_27())
                    {
                        asyncState.imethod_10().method_2();
                        if (!(base.bool_0 || asyncState.imethod_6()))
                        {
                            asyncState.GetStream().BeginRead(asyncState.method_4(), 0, this.interface46_0.imethod_9(), new AsyncCallback(this.ServeOverLap), asyncState);
                        }
                        asyncState.imethod_10().method_4(class3);
                    }
                    else
                    {
                        base.OnMessageReceived(asyncState, class3);
                        if (!(base.bool_0 || asyncState.imethod_6()))
                        {
                            asyncState.GetStream().BeginRead(asyncState.method_4(), 0, this.interface46_0.imethod_9(), new AsyncCallback(this.ServeOverLap), asyncState);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                if ((exception is IOException) || (exception is ObjectDisposedException))
                {
                    base.OnSomeOneDisconnected(asyncState, DisconnectedType.NetworkInterrupted);
                }
                else
                {
                    base.emptyAgileLogger_0.Log(exception, "CJFramework.Engine.Tcp.Server.StreamTcpEngine.ServeOverLap", ErrorLevel.High);
                }
            }
        }
    }