예제 #1
0
    public int DispatchEvent(MsgData data)
    {
        int iRet = 0;

        if (eventTable.ContainsKey(data.Cmd))
        {
            List <EventHandleMsg> evtList = eventTable[data.Cmd];
            List <EventHandleMsg> clone   = new List <EventHandleMsg>(evtList);
            for (int i = 0; i < clone.Count; i++)
            {
                EventHandleMsg hd = clone[i];
                if (null != hd)
                {
                    hd(data);
                }
            }
        }

        if (key2PackageRegistry.ContainsKey(data.Cmd))
        {
            //如果是关键包,记录后待删除
            RecordReceiveCMD(data.Cmd);
            Pop(data.Cmd);
        }

        //通知停止锁屏
        bool canUnlock = _lockManager.RemovePackageCmd(data.Cmd);

        if (canUnlock)
        {
            EventManager.Send(EventType_Net.EVENT_UNLOCK_SCREEN);
        }
        return(iRet);
    }
예제 #2
0
    //注册,模块可以注册自己关心的协议id,设置回调函数
    public void Regist(CS_CMD_ID CmdType, EventHandleMsg CallBack, EventHandleTimeOut CallBackTimeout = null)
    {
        UInt16 cmd = (UInt16)CmdType;

        if (cmd > 0 && CallBack != null)
        {
            EventHandleMsg handle = CallBack;
            AddFun(cmd, handle);
        }


        if (cmd > 0 && CallBackTimeout != null)
        {
            EventHandleTimeOut handle = CallBackTimeout;
            AddTimeoutFun(cmd, handle);
        }
    }
예제 #3
0
    private void AddFun(UInt16 cmd, EventHandleMsg delgate)
    {
        EventHandleMsg        Handle  = delgate;
        List <EventHandleMsg> evtList = null;

        if (eventTable.ContainsKey(cmd))
        {
            evtList = eventTable[cmd];
            if (!evtList.Contains(Handle))
            {
                evtList.Add(Handle);
            }
        }
        else
        {
            evtList = new List <EventHandleMsg>();
            evtList.Add(Handle);
            eventTable[cmd] = evtList;
        }
    }
예제 #4
0
    public void UnRegist(CS_CMD_ID CmdType, EventHandleMsg Handle, EventHandleTimeOut CallBackTimeout = null)
    {
        UInt16 cmd = (UInt16)CmdType;

        if (eventTable.ContainsKey(cmd))
        {
            List <EventHandleMsg> evtList = eventTable[cmd];
            evtList.Remove(Handle);
        }

        if (handleTimeOut.ContainsKey(cmd))
        {
            List <EventHandleTimeOut> timeOutList = handleTimeOut[cmd];
            if (null != CallBackTimeout)
            {
                if (timeOutList.Contains(CallBackTimeout))
                {
                    timeOutList.Remove(CallBackTimeout);
                }
            }
        }
    }
예제 #5
0
파일: ServerCenter.cs 프로젝트: ghrguse/ss
 public void UnRegist(CS_CMD_ID CmdType, EventHandleMsg Handle, EventHandleTimeOut CallBackTimeout = null)
 {
     _gameSvrProtoUtil.UnRegist(CmdType, Handle, CallBackTimeout);
 }