Ejemplo n.º 1
0
        private void OnMercuryEvent(object sender, MercuryEventBase e)
        {
            if (e.eventId == (int)EMercuryEvent.E_ME_OBJ_DELIVER)
            {
                MEObjDeliver evt = (MEObjDeliver)e;
                if (evt.opcode == (int)EObjDeliverOPCode.E_OP_HANDLE_FRAMEPACK)
                {
                    object[] args = (object[])evt.obj;
                    if (!HandleFrameCommandPackage((uint)args[0], args[1]))
                    {
                        uint frameID = (uint)args[0];
                        if (frameID >= _begFrqNo)
                        {
                            FrapWrap wrap = ObjectCachePool.instance.Fetch <FrapWrap>();
                            wrap.frameID = frameID;
                            wrap.data    = args[1];

                            //Èç¹û¸ÃÖ¡ÒÑ´æÔÚ£¬Ôò¶ªÆú
                            if (!Utility.LinkedListInsert(_laterFrames, wrap, FrapWrap.FrapWrapInsertComparsionFunc))
                            {
                                ProcessFrameDropInternal(frameID, wrap.data, false);
                                wrap.Release();
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        //
        private void PushFrame2LaterFrameList(MercuryEventBase e)
        {
            if (e != null)
            {
                MEObjDeliver evt  = (MEObjDeliver)e;
                FrapWrap     frap = ObjectCachePool.instance.Fetch <FrapWrap>();
                frap.frameID = (uint)evt.args[0];
                frap.data    = evt.args[1];
                e.Release();

                if (Utility.LinkedListInsert(_laterFrames, frap, FrapWrap.FrapWrapInsertComparsionFunc))
                {
                    if (_lastFrameNeedToTrace < frap.frameID)
                    {
                        _lastFrameNeedToTrace = (int)frap.frameID; // record last frame while tracing the newest frame.
                    }
                }
                else
                {
                    // release duplicated data
                    AbstractSmartObj obj = (AbstractSmartObj)frap.data;
                    if (obj != null)
                    {
                        obj.Release();
                    }
                    frap.Release();
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 如果该帧是断线重连时请求的延迟帧,则优先处理,并上报进度。如果是最新的服务器帧,则稍后处理
 /// </summary>
 /// <param name="e"></param>
 /// <param name="isLaterFrame">1 表示断线重连状态中,发送过来的最新服务器帧, 2 表示重连时请求的延迟帧</param>
 public void HandleFrames(MercuryEventBase e, bool isLaterFrame = false)
 {
     if (!isLaterFrame)
     {
         uint frapNo = (uint)(((MEObjDeliver)e).args[0]);
         if (_currentFrameTraced < (int)frapNo)
         {
             _currentFrameTraced = (int)frapNo;
         }
         Mercury.instance.Broadcast(EventTokenTable.et_framewindow, this, e);
         ReportProgress();
     }
     else
     {
         PushFrame2LaterFrameList(e);
     }
 }