Example #1
0
 private void OnReceive(GameNetWork.SockMsgRouter router, IProtocolHead ph)
 {
     if (mAction != null)
     {
         mAction(router, ph);
     }
     UnRegister();
 }
Example #2
0
        public virtual void RegisterOperationErrorSockHandler <T>(SockMsgRouter.OperateErrorHandler handler, int channel = 0) where T : IProtocolHead
        {
            SockMsgRouter router = GetRouter(channel);
            UInt16        appCode = 0, funcCode = 0;
            byte          flag = 0;

            GetProtoArgs <T>(out appCode, out funcCode, out flag);

            router.RegisterOperationErrorMsgHandler(appCode, funcCode, handler);
        }
Example #3
0
        public virtual void SockConnect(string ip, int port, int channel, Action callback, Action disconnected = null)
        {
            SockMsgRouter router = GetRouter(channel);

            StreamSock sock = sockMgr.Connect(ip, port, callback);

            sock.Router = router;
            router.ClearBuff(false);
            sock.socketDisconnection += disconnected;
        }
Example #4
0
 private SockMsgRouter GetRouter(int channel)
 {
     if (null == routers[channel])
     {
         routers[channel] = new SockMsgRouter();
         routers[channel].Start();
         routers[channel].blockGameMsgBack += RemoveGameMask;
         if (channel == SOCK_GAME_CHANNEL)
         {
             routers[channel].timeoutHandler += Timeout;
         }
     }
     return(routers [channel]);
 }
Example #5
0
        public virtual void Update()
        {
            if (sockMgr != null)
            {
                sockMgr.Update();
            }

            for (int i = 0; i < routers.Length; i++)
            {
                SockMsgRouter sockMsgRouter = routers[i];
                if (null != sockMsgRouter)
                {
                    sockMsgRouter.Update();
                }
            }
        }
Example #6
0
        public virtual void ShutDown()
        {
            if (null != httpMsgRouter)
            {
                httpMsgRouter.Shutdown();
                httpMsgRouter = null;
            }

            for (int i = 0; i < routers.Length; i++)
            {
                SockMsgRouter sockMsgRouter = routers[i];
                if (null != sockMsgRouter)
                {
                    SockDisConnect(i);
                    sockMsgRouter.Shutdown();
                    routers[i] = null;
                }
            }
            sockMgr.Shutdown();
        }
Example #7
0
 public OperationQueue(SockMsgRouter router)
 {
     this.router = router;
 }