private NetDataBuf AddQueueOneCompleteCommand(byte[] buf) { NetDataBuf netBuf = new NetDataBuf(null, buf, byteType); NetDataCenter.Instance.AddQueueReceive(netBuf); return(netBuf); }
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(); }
public bool GetQueueSend(ref NetDataBuf sendBuf) { if (mQueueSend.Count > 0) { sendBuf = (NetDataBuf)mQueueSend.Dequeue(); return(true); } return(false); }
public NetDataBuf Clone() { NetDataBuf clone = new NetDataBuf(null, byteBuf, ByteType.Single); clone.DataOffset = DataOffset; clone.DataLen = DataLen; clone.FullDataLen = FullDataLen; return(clone); }
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); }
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(""); }
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); }
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; } }
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 发送线程退出"); }
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); }
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); }
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); } }
private void SendCmd(byte[] buf, ByteType byteType, Socket socket) { NetDataBuf netData = new NetDataBuf(socket, buf, byteType); NetDataCenter.Instance.AddQueueSend(netData); }
public void AddQueueSend(NetDataBuf sendBuf) { mQueueSend.Enqueue(sendBuf); }
public void AddQueueReceive(NetDataBuf sendBuf) { mQueueCommand.Enqueue(sendBuf); }