Exemplo n.º 1
0
        public static NetSendPacket New(string route, JsonObject data, uint id)
        {
            NetSendPacket packet = NetVendor.GetInstance()[NetVendor.PoolKey.SendPacket].Spawn <NetSendPacket>();

            packet.InitData(route, data, id);
            packet.Retain();//计数器+1;
            return(packet);
        }
Exemplo n.º 2
0
        protected object onCreatObject(object poolKey, SpawnPool2 pool)
        {
            object obj = null;

            switch ((PoolKey)poolKey)
            {
            case PoolKey.SendPacket:
                obj = new NetSendPacket();
                break;
            }
            return(obj);
        }
Exemplo n.º 3
0
        //
        public void SendJsonMsg(string route, JsonObject data)
        {
            if (string.IsNullOrEmpty(route))
            {
                return;
            }

            if (route.Equals(MSG_Query_Connector))
            {
                //最前面 //清理掉久的
                if (mSendCmdList.Count > 0)
                {
                    uint first = mSendCmdList[0];
                    if (mSendDict.ContainsKey(first) && (mSendDict[first].mRoute == MSG_Query_Connector))
                    {
                        mSendDict[first].Release();
                        mSendDict.Remove(first);
                        mSendCmdList.RemoveAt(0);
                    }
                }

                //暂时如此加入字典,为后续报错确定位置
                NetSendPacket msg = NetSendPacket.New(route, data, mReqId);
                //追加
                mSendCmdList.Insert(0, msg.mId);
                mSendDict[msg.mId] = msg;
                if (mReqId == uint.MaxValue)
                {
                    mReqId = 0;
                }
                mReqId++;
                return;
            }
            else
            {
                //暂时如此加入字典,为后续报错确定位置
                NetSendPacket msg = NetSendPacket.New(route, data, mReqId);
                //追加
                mSendCmdList.Add(msg.mId);
                mSendDict[msg.mId] = msg;
                if (mReqId == uint.MaxValue)
                {
                    mReqId = 0;
                }
                mReqId++;
            }
        }
Exemplo n.º 4
0
 //-------------------------------发送相关-------------------------------------
 /// <summary>
 /// 处理发送队列的消息
 /// </summary>
 private void HandleSendMsgUpdate()
 {
     if (mSendCmdList.Count > 0 && (_pomeloClient != null))
     {
         if ((_workState == WorkState.ConnectGameSvrSuccessed || _workState == WorkState.ConnectGateQueryGSvrState || _workState == WorkState.ConnectGateQueryGSvrWaitingState))
         {
             NetSendPacket packet = null;
             for (int i = 0; i < mSendCmdList.Count; i++)
             {
                 if (mSendDict.TryGetValue(mSendCmdList[i], out packet))
                 {
                     //查询服务器地址
                     if (packet.mRoute.Equals(MSG_Query_Connector))
                     {
                         if (!packet.mSended)
                         {
                             //设置已经发送标识
                             packet.SetSended();
                             //Real Send
                             _pomeloClient.request(packet.mRoute, packet.mId, packet.mData);
                             return;
                         }
                     }
                     else
                     {
                         //判断是否已经发送过了,发送过了就不用再发送了
                         if (!packet.mSended)
                         {
                             //设置已经发送标识
                             packet.SetSended();
                             if (packet.ReSended)
                             {
                                 JW.Common.Log.LogD("<color=yellow>[Net Send Again]</color>:Type:{0}", packet.mRoute);
                             }
                             //Real Send
                             _pomeloClient.request(packet.mRoute, packet.mId, packet.mData);
                             return;
                         }
                     }
                 }
             }
         }
     }
 }