Пример #1
0
 public void Cycle()
 {
     if (Playback.Video != null)
     {
         Playback.Video.Cycle();
     }
     if (this._inputQueue.Length <= 0)
     {
         return;
     }
     try
     {
         PacketHandlers.BeginSlice();
         lock (this._inputQueue)
         {
             while (this._inputQueue.Length > 0)
             {
                 int local_0 = this._inputQueue.GetPacketId();
                 if (local_0 < 0)
                 {
                     break;
                 }
                 PacketHandler local_1 = PacketHandlers.m_Handlers[local_0];
                 if (local_1 != null)
                 {
                     int local_2 = local_1.Length;
                     if (local_2 == -1)
                     {
                         local_2 = this._inputQueue.GetPacketLength();
                         if (local_2 < 3)
                         {
                             if (local_2 < 0)
                             {
                                 break;
                             }
                             this._inputQueue.Clear();
                             break;
                         }
                     }
                     if (this._inputQueue.Length < local_2)
                     {
                         break;
                     }
                     ArraySegment <byte> local_3 = this._inputQueue.Dequeue(local_2);
                     PacketReader        local_4 = PacketReader.Initialize(local_3.Array, local_3.Offset, local_3.Count, local_1.Length != -1, (byte)local_0, local_1.Callback.Method.Name);
                     if (this._networkDiagnostics != null)
                     {
                         foreach (INetworkDiagnostic item_0 in this._networkDiagnostics)
                         {
                             item_0.PacketReceived(local_1, local_3.Array, local_3.Offset, local_3.Count);
                         }
                     }
                     if (!Playback.Active || local_1.PacketID == 115)
                     {
                         local_1.Handle(local_4);
                     }
                     NetworkContext.prior3 = NetworkContext.prior2;
                     NetworkContext.prior2 = NetworkContext.prior1;
                     NetworkContext.prior1 = local_0;
                 }
                 else
                 {
                     ArraySegment <byte> local_6 = this._inputQueue.Dequeue(this._inputQueue.Length);
                     PacketReader.Initialize(local_6.Array, local_6.Offset, local_6.Count, true, (byte)local_0, "Unknown").Trace(false);
                     NetworkContext.prior3 = NetworkContext.prior2;
                     NetworkContext.prior2 = NetworkContext.prior1;
                     NetworkContext.prior1 = local_0;
                     break;
                 }
             }
         }
     }
     finally
     {
         PacketHandlers.FinishSlice();
     }
 }