Esempio n. 1
0
        protected void HandleSubMsg(byte[] data)
        {
            UInt16        appCode = 0, funcCode = 0;
            int           opCode = 0;
            IProtocolHead ph     = PackageUtils.Deserialize2Proto(data, ref appCode, ref funcCode, ref opCode, false);

            if (null == ph)
            {
                return;
            }

            if (ph is ProtoVO.common.packet)
            {
                ProtoVO.common.packet packet = ph as ProtoVO.common.packet;
//				for(int i = 0; i < packet.batchPackets.Count; i++)
//				{
//					HandleSubMsg(packet.batchPackets[i].packet);
//				}
                return;
            }

            Operation op = operationQueue.OnRecieve(opCode);
            int       id = PackageUtils.GetProtocolID(appCode, funcCode);

            if (!handlerMap.ContainsKey(id))
            {
//				Logger.LogWarning("Can't find handler for " + AppFnMapping.MAPPING[funcCode].Name);
                return;
            }
            HandleCallBack(ph, id, op, opCode);
            HandleOperationError(appCode, funcCode, op, ph);
        }
Esempio n. 2
0
        protected override void HandleMsg(byte[] data)
        {
            Debug.Log("recieved message");
            UInt16        appCode = 0, funcCode = 0;
            int           opCode = 0;
            IProtocolHead ph     = PackageUtils.Deserialize2Proto(data, ref appCode, ref funcCode, ref opCode);

            if (null == ph)
            {
                return;
            }

//			if(ph is ProtoVO.common.packet)
//			{
//				ProtoVO.common.packet packet = ph as ProtoVO.common.packet;
//				for(int i = 0; i < packet.batchPackets.Count; i++)
//				{
//					HandleSubMsg(packet.batchPackets[i].packet);
//				}
//				return;
//			}
//			else if(ph is ProtoVO.user.UserSyncReq)
//			{Logger.Log("Reconnect finish");
//
//				ProtoVO.user.UserSyncReq sync = ph as ProtoVO.user.UserSyncReq;
//
//				for(int i = 0; i < sync.jobQueues.Count; i++)
//				{
//					HandleSubMsg(sync.jobQueues[i].packet);
//				}
//				if(sync.userInfo != null && sync.userInfo.packet != null)
//					HandleSubMsg(sync.userInfo.packet);
//				if( blockGameMsgBack != null)
//					blockGameMsgBack.Invoke();
//			}

            Operation op = operationQueue.OnRecieve(opCode);
            int       id = PackageUtils.GetProtocolID(appCode, funcCode);

//            if (!handlerMap.ContainsKey(id))
//            {
//                Logger.LogWarning("Can't find handler for " + AppFnMapping.MAPPING[funcCode].Name);
//                return;
//            }
            HandleCallBack(ph, id, op, opCode);
            HandleOperationError(appCode, funcCode, op, ph);
        }
Esempio n. 3
0
        protected override void HandleMsg(string url, MsgWrap mwrap)
        {
            UInt16 appCode = 0, funcCode = 0;
            int    opCode = 0;

            if (!mwrap.req.needResponse)
            {
                return;
            }
            byte[]        data = mwrap.rsp.result;
            IProtocolHead ph   = PackageUtils.Deserialize2Proto(data, ref appCode, ref funcCode, ref opCode);

            if (null == ph)
            {
                Debug.LogError("package error: " + url);
                Debug.LogError(Convert.ToBase64String(data));
                return;
            }

            int id = PackageUtils.GetProtocolID(appCode, funcCode);

//			if(mwrap.req._callback != null)
//			{
//				mwrap.req._callback(url, ph);
//			}

            if (!handlerDic.ContainsKey(id))
            {
                Logger.LogWarning("Can't find handler for " + appCode + " | " + funcCode);
                return;
            }

            Delegate handler = handlerDic[id];

            if (null != handler)
            {
                ((MsgHandler)handler)(url, ph);
            }
        }