Exemplo n.º 1
0
 void IZoneNodePlayer.ClientFlush(BattleCodec codec)
 {
     try
     {
         if (pause_logic == false)
         {
             lock (mLogicSendingQueue)
             {
                 if (mLogicSendingQueue.Count > 0)
                 {
                     remote_logic?.BatchInvoke(mLogicSendingQueue);
                     mLogicSendingQueue.Clear();
                 }
             }
         }
         if (pause_client == false)
         {
             if (mSendingQueue.events.Count > 0)
             {
                 mSendingQueue.sequenceNo = node.ZoneNode.ZoneTick;
                 using (var buffer = MemoryStreamObjectPool.AllocAutoRelease())
                 {
                     try
                     {
                         if (codec.doEncodeWithHead(mSendingQueue, buffer))
                         {
                             var notify = BinaryMessage.FromBuffer(client_event_route, buffer);
                             remote_session?.WormholeTransport(notify);
                         }
                     }
                     catch (Exception err)
                     {
                         log.Error(err.Message, err);
                     }
                     finally
                     {
                         mSendingQueue.events.Clear();
                     }
                 }
             }
         }
     }
     catch (Exception err)
     {
         log.Error(err.Message, err);
     }
 }