コード例 #1
0
        private void ProcessData()
        {
            if (package.Length <= 4 || package.ReadIndex < 0)
            {
                return;
            }
            int dataLength = BitConverter.ToInt32(package.Bytes, package.ReadIndex);

            if (package.Length < dataLength + 4)
            {
                return;
            }
            package.ReadIndex += 4;
            try
            {
                T data = NetTool.Deserialize <T>(package.Bytes, package.ReadIndex, dataLength);
                OnReceiveData(data);
            }
            catch (Exception e)
            {
                DetailLog.Error("ProcessDataError:" + e.Message);
                return;
            }
            package.ReadIndex += dataLength;
            package.CheckAndMoveBytes();

            if (package.Length > 4)
            {
                ProcessData();
            }
        }
コード例 #2
0
 public void SendData(T data)
 {
     byte[] sendData = NetTool.PackNetData(data);
     SendData(sendData);
 }