Пример #1
0
        internal virtual bool DeserializeMessageAndCallback(byte[] inBuff)
        {
            bool flag = inBuff.Length < 2;
            bool result;

            if (flag)
            {
                bool flag2 = this.debugOut >= DebugLevel.ERROR;
                if (flag2)
                {
                    this.Listener.DebugReturn(DebugLevel.ERROR, "Incoming UDP data too short! " + inBuff.Length);
                }
                result = false;
            }
            else
            {
                bool flag3 = inBuff[0] != 243 && inBuff[0] != 253;
                if (flag3)
                {
                    bool flag4 = this.debugOut >= DebugLevel.ERROR;
                    if (flag4)
                    {
                        this.Listener.DebugReturn(DebugLevel.ALL, "No regular operation UDP message: " + inBuff[0]);
                    }
                    result = false;
                }
                else
                {
                    byte         b            = inBuff[1] & 127;
                    bool         flag5        = (inBuff[1] & 128) > 0;
                    StreamBuffer streamBuffer = null;
                    bool         flag6        = b != 1;
                    if (flag6)
                    {
                        try
                        {
                            bool flag7 = flag5;
                            if (flag7)
                            {
                                inBuff       = this.CryptoProvider.Decrypt(inBuff, 2, inBuff.Length - 2);
                                streamBuffer = new StreamBuffer(inBuff);
                            }
                            else
                            {
                                streamBuffer = new StreamBuffer(inBuff);
                                streamBuffer.Seek(2L, SeekOrigin.Begin);
                            }
                        }
                        catch (Exception ex)
                        {
                            bool flag8 = this.debugOut >= DebugLevel.ERROR;
                            if (flag8)
                            {
                                this.Listener.DebugReturn(DebugLevel.ERROR, ex.ToString());
                            }
                            SupportClass.WriteStackTrace(ex);
                            result = false;
                            return(result);
                        }
                    }
                    int num = 0;
                    switch (b)
                    {
                    case 1:
                        this.InitCallback();
                        goto IL_360;

                    case 3:
                    {
                        OperationResponse operationResponse = this.protocol.DeserializeOperationResponse(streamBuffer);
                        bool trafficStatsEnabled            = this.TrafficStatsEnabled;
                        if (trafficStatsEnabled)
                        {
                            this.TrafficStatsGameLevel.CountResult(this.ByteCountCurrentDispatch);
                            num = SupportClass.GetTickCount();
                        }
                        this.Listener.OnOperationResponse(operationResponse);
                        bool trafficStatsEnabled2 = this.TrafficStatsEnabled;
                        if (trafficStatsEnabled2)
                        {
                            this.TrafficStatsGameLevel.TimeForResponseCallback(operationResponse.OperationCode, SupportClass.GetTickCount() - num);
                        }
                        goto IL_360;
                    }

                    case 4:
                    {
                        EventData eventData            = this.protocol.DeserializeEventData(streamBuffer);
                        bool      trafficStatsEnabled3 = this.TrafficStatsEnabled;
                        if (trafficStatsEnabled3)
                        {
                            this.TrafficStatsGameLevel.CountEvent(this.ByteCountCurrentDispatch);
                            num = SupportClass.GetTickCount();
                        }
                        this.Listener.OnEvent(eventData);
                        bool trafficStatsEnabled4 = this.TrafficStatsEnabled;
                        if (trafficStatsEnabled4)
                        {
                            this.TrafficStatsGameLevel.TimeForEventCallback(eventData.Code, SupportClass.GetTickCount() - num);
                        }
                        goto IL_360;
                    }

                    case 7:
                    {
                        OperationResponse operationResponse = this.protocol.DeserializeOperationResponse(streamBuffer);
                        bool trafficStatsEnabled5           = this.TrafficStatsEnabled;
                        if (trafficStatsEnabled5)
                        {
                            this.TrafficStatsGameLevel.CountResult(this.ByteCountCurrentDispatch);
                            num = SupportClass.GetTickCount();
                        }
                        bool flag9 = operationResponse.OperationCode == PhotonCodes.InitEncryption;
                        if (flag9)
                        {
                            this.DeriveSharedKey(operationResponse);
                        }
                        else
                        {
                            bool flag10 = operationResponse.OperationCode == PhotonCodes.Ping;
                            if (flag10)
                            {
                                TPeer tPeer  = this as TPeer;
                                bool  flag11 = tPeer != null;
                                if (flag11)
                                {
                                    tPeer.ReadPingResult(operationResponse);
                                }
                                else
                                {
                                    this.EnqueueDebugReturn(DebugLevel.ERROR, "Ping response not used. " + operationResponse.ToStringFull());
                                }
                            }
                            else
                            {
                                this.EnqueueDebugReturn(DebugLevel.ERROR, "Received unknown internal operation. " + operationResponse.ToStringFull());
                            }
                        }
                        bool trafficStatsEnabled6 = this.TrafficStatsEnabled;
                        if (trafficStatsEnabled6)
                        {
                            this.TrafficStatsGameLevel.TimeForResponseCallback(operationResponse.OperationCode, SupportClass.GetTickCount() - num);
                        }
                        goto IL_360;
                    }
                    }
                    this.EnqueueDebugReturn(DebugLevel.ERROR, "unexpected msgType " + b);
IL_360:
                    result = true;
                }
            }
            return(result);
        }