private void OnReceive(GameNetWork.SockMsgRouter router, IProtocolHead ph) { if (mAction != null) { mAction(router, ph); } UnRegister(); }
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); }
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; }
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]); }
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(); } } }
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(); }
public OperationQueue(SockMsgRouter router) { this.router = router; }