本文整理汇总了C#中ByteArray.Uncompress方法的典型用法代码示例。如果您正苦于以下问题:C# ByteArray.Uncompress方法的具体用法?C# ByteArray.Uncompress怎么用?C# ByteArray.Uncompress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ByteArray
的用法示例。
在下文中一共展示了ByteArray.Uncompress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReceiveCallback
private void ReceiveCallback(IAsyncResult ar)
{
try
{
StateObject stateObj = (StateObject)ar.AsyncState;
Socket client = stateObj.workSocket;
int bytesRead = client.EndReceive(ar);
//Debug.Log("收到字节数:" + bytesRead);
if (bytesRead > 0)
{
byte[] byteData = new byte[bytesRead];
Array.Copy(stateObj.buffer, byteData, byteData.Length);
_dealingData = new ByteArray();
_dealingData.writeBytes(stateObj.buffer,0,bytesRead);
byte[] buff = _dealingData.Buffer;
int i = _dealingData.Length;
_dealingData.Postion = 0;
while (_dealingData.Length >= 5)
{
_voLength = _dealingData.readInt(); //4个字节
byte[] buff2 = _dealingData.Buffer;
if (_dealingData.Length >= _voLength)
{
_isZIP = _dealingData.readUnsignedByte(); //1字节
_voData = new ByteArray();
if (_voLength > 1)
{ //排除空包
_voData.writeBytes(_dealingData.Buffer,_dealingData.Postion,_voLength-1);
_voData.Postion = 0;
if (_isZIP == 1)
{
_voData.Uncompress();
}
decodeData2(_voData);
}
}
else
{ //数据不足,退回_voLength
_dealingData.Postion = _dealingData.Postion - 4;
break;
}
}
client.BeginReceive(stateObj.buffer, 0, stateObj.BufferSize, SocketFlags.None, new AsyncCallback(ReceiveCallback), stateObj);
}
else
{
//服务器崩溃了
//MessageBox.Show("出错了!");
//ReceiveCallback
Debug.Log("注销登录(服务器崩溃)...");
stateObj.workSocket.Shutdown(SocketShutdown.Both);
stateObj.workSocket.Close();
}
}
catch (SocketException ex)
{
//服务器崩溃了
Debug.Log("注销登录(服务器崩溃)...");
stateObj.workSocket.Shutdown(SocketShutdown.Both);
stateObj.workSocket.Close();
}
}