示例#1
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);
        }
    }
示例#2
0
 //超时处理
 private void CallHandleTimeout(UInt16 cmd)
 {
     delelist.Add(cmd);
     if (handleTimeOut.ContainsKey(cmd))
     {
         List <EventHandleTimeOut> evtList = handleTimeOut[cmd];
         if (null != evtList && 0 != evtList.Count)
         {
             for (int i = evtList.Count - 1; i >= 0; i--)
             {
                 EventHandleTimeOut handle = evtList[i];
                 if (null != handle)
                 {
                     handle();
                 }
             }
         }
     }
 }
示例#3
0
    private void AddTimeoutFun(UInt16 cmd, EventHandleTimeOut delgate)
    {
        EventHandleTimeOut        Handle      = delgate;
        List <EventHandleTimeOut> timeOutList = null;

        if (handleTimeOut.ContainsKey(cmd))
        {
            timeOutList = handleTimeOut[cmd];

            if (!timeOutList.Contains(Handle))
            {
                timeOutList.Add(Handle);
            }
        }
        else
        {
            timeOutList = new List <EventHandleTimeOut>();
            timeOutList.Add(Handle);
            handleTimeOut.Add(cmd, timeOutList);
        }
    }
示例#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
 public void UnRegist(CS_CMD_ID CmdType, EventHandleMsg Handle, EventHandleTimeOut CallBackTimeout = null)
 {
     _gameSvrProtoUtil.UnRegist(CmdType, Handle, CallBackTimeout);
 }