Exemple #1
0
        private NetDataBuf AddQueueOneCompleteCommand(byte[] buf)
        {
            NetDataBuf netBuf = new NetDataBuf(null, buf, byteType);

            NetDataCenter.Instance.AddQueueReceive(netBuf);
            return(netBuf);
        }
Exemple #2
0
        private void ParseVersion(NetDataBuf dataBuf)
        {
            string[] arrstr = dataBuf.sb.ToString().Split('/');
            int      index  = 2;

            GameInfoCenter.Instance.GetGameInfo(GameType.麻将).Version_Server = Int32.Parse(arrstr[index]);
            Hall_GameApp.Instance.CheckHallUpdate();
        }
Exemple #3
0
 public bool GetQueueSend(ref NetDataBuf sendBuf)
 {
     if (mQueueSend.Count > 0)
     {
         sendBuf = (NetDataBuf)mQueueSend.Dequeue();
         return(true);
     }
     return(false);
 }
Exemple #4
0
        public NetDataBuf Clone()
        {
            NetDataBuf clone = new NetDataBuf(null, byteBuf, ByteType.Single);

            clone.DataOffset  = DataOffset;
            clone.DataLen     = DataLen;
            clone.FullDataLen = FullDataLen;
            return(clone);
        }
Exemple #5
0
 public bool GetLastRecDataBuf(ref NetDataBuf data)
 {
     if (mQueueCommand.Count > 0)
     {
         object[] dataAry = (object[])mQueueCommand.ToArray();
         data = (NetDataBuf)dataAry[dataAry.Length - 1];
         return(true);
     }
     return(false);
 }
Exemple #6
0
 public string GetCommand(ref List <string> strList, ref NetDataBuf dataBuf)
 {
     if (NetDataCenter.Instance.GetQueueReceive(ref dataBuf))
     {
         string[] arrstr = dataBuf.sb.ToString().Split('/');
         for (int i = 2; i < arrstr.Length; i++)
         {
             strList.Add(arrstr[i]);
         }
         return(arrstr[0]);
     }
     return("");
 }
Exemple #7
0
        private void SendCmd(byte[] buf, ByteType byteType)
        {
            NetDataBuf netData = null;

            if (byteType == ByteType.Single)
            {
                netData = new NetDataBuf(_socket, buf, byteType);
            }
            //else
            //    netData = new NetDataBuf(_socket_Chinese, buf, byteType);

            NetDataCenter.Instance.AddQueueSend(netData);
        }
Exemple #8
0
 private void ParseQueueOneCommand(byte[] buf, int iTotalDataLen, int iDataOffset)
 {
     if (buf.Length >= iTotalDataLen)
     {
         LastNetBuf = AddQueueOneCompleteCommand(buf);
     }
     else
     {
         NetDataBuf netBuf = new NetDataBuf(null, buf, byteType);
         netBuf.FullDataLen = iTotalDataLen;
         netBuf.DataOffset  = iDataOffset;
         LastNetBuf         = netBuf;
     }
 }
Exemple #9
0
        private void SendThread()
        {
            NetDataBuf netDataBuf = null;

            while (true)
            {
                if (NetDataCenter.Instance.GetQueueSend(ref netDataBuf))
                {
                    netDataBuf.Send();
                }
                System.Threading.Thread.Sleep(SEND_DELAY);
                //timeDelay(SEND_DELAY);
            }
            Debuger.Log("NetworkClient 发送线程退出");
        }
Exemple #10
0
 public bool GetQueueReceive(ref NetDataBuf data)
 {
     if (mQueueCommand.Count > 0)
     {
         //data = (NetDataBuf)mQueueCommand.Peek();
         data = (NetDataBuf)mQueueCommand.Dequeue();
         if (data.IsFullDataPacket)
         {
             return(true);
         }
         else
         {
             AddQueueReceive(data);
             return(false);
         }
     }
     return(false);
 }
Exemple #11
0
        public string GetCmdType()
        {
            mCmdStrList.Clear();
            NetDataBuf dataBuf = null;
            string     type    = network.GetCommand(ref mCmdStrList, ref dataBuf);

            if (type != "")
            {
                Debuger.Log("GetCommand :" + type);
                switch (type)
                {
                case "GETVER":
                    ParseVersion(dataBuf);
                    break;

                default: break;
                }
            }
            return(type);
        }
Exemple #12
0
        private void ParseDecodeBuf(byte[] buf, int len)
        {
            byte[] store_buf = new byte[len];
            Array.Copy(buf, store_buf, len);

            string context = GetStringContext(store_buf, len);

            string[] arrstr = context.Split('/');
            Debuger.Log(string.Format("AddOneCommand:{0}", arrstr[0]));
            if (arrstr[0] == "WXTX" || arrstr[0] == "YUYING")
            {
                int packTotalLen   = Int32.Parse(arrstr[4]);
                int packId         = Int32.Parse(arrstr[3]);
                int packLen        = Int32.Parse(arrstr[5]);
                int dataStartIndex = len - packLen;


                if (packId == 0)
                {
                    ParseQueueOneCommand(store_buf, packTotalLen, dataStartIndex);
                }
                else
                {
                    byte[] dataAry = new byte[packLen];
                    Array.Copy(store_buf, dataStartIndex, dataAry, 0, packLen);

                    LastNetBuf.AddData(dataAry, byteType);
                    if (LastNetBuf.IsFullDataPacket == true)
                    {
                        NetDataCenter.Instance.AddQueueReceive(LastNetBuf.Clone());
                        LastNetBuf = null;
                    }
                }
            }
            else
            {
                ParseQueueOneCommand(store_buf, len, 0);
            }
        }
Exemple #13
0
        private void SendCmd(byte[] buf, ByteType byteType, Socket socket)
        {
            NetDataBuf netData = new NetDataBuf(socket, buf, byteType);

            NetDataCenter.Instance.AddQueueSend(netData);
        }
Exemple #14
0
 public void AddQueueSend(NetDataBuf sendBuf)
 {
     mQueueSend.Enqueue(sendBuf);
 }
Exemple #15
0
 public void AddQueueReceive(NetDataBuf sendBuf)
 {
     mQueueCommand.Enqueue(sendBuf);
 }