本文整理汇总了C#中ZyGames.Framework.RPC.IO.MessageStructure.WriteGzipBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# MessageStructure.WriteGzipBuffer方法的具体用法?C# MessageStructure.WriteGzipBuffer怎么用?C# MessageStructure.WriteGzipBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZyGames.Framework.RPC.IO.MessageStructure
的用法示例。
在下文中一共展示了MessageStructure.WriteGzipBuffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Receive
//.........这里部分代码省略.........
#endif
var settings = ParseRequestSettings(paramGeter, remoteAddress);
settings.ParamString = paramString;
settings.RouteName = routeName;
byte[] sendBuffer = new byte[0];
RequestError error = RequestError.Success;
try
{
if (isRoute)
{
if (CheckCallAccessLimit(remoteAddress))
{
error = RequestError.Unknown;
head.ErrorInfo = ErrorCallAccessLimit;
}
else
{
ServiceRequest.CallRemote(settings, out sendBuffer);
}
}
else
{
ServiceRequest.Request(settings, out sendBuffer);
}
}
catch (CommunicationObjectFaultedException fault)
{
TraceLog.WriteError("The wcfclient request faulted:{0}", fault);
error = RequestError.Closed;
ServiceRequest.ResetChannel(settings);
}
catch (Exception ex)
{
if (ex.InnerException is SocketException)
{
var sex = ex.InnerException as SocketException;
TraceLog.WriteError("The wcfclient request connect:{0}-{1}", sex.SocketErrorCode, sex);
if (sex.SocketErrorCode == SocketError.TimedOut)
{
error = RequestError.Timeout;
}
else
{
error = RequestError.UnableConnect;
}
}
else
{
TraceLog.WriteError("The wcfclient request error:{0}", ex);
error = RequestError.Unknown;
}
ServiceRequest.ResetChannel(settings);
}
watch.Stop();
switch (error)
{
case RequestError.Success:
ms.WriteGzipBuffer(sendBuffer);
string msg = string.Format("[{0}]请求响应{1}:route={8},MsgId={2},St={3},Action-{4},error:{5}-{6},bytes:{7},响应时间:{9}ms\r\n",
DateTime.Now.ToLongTimeString(),
session.RemoteAddress,
head.MsgId,
head.St,
head.Action,
head.ErrorCode,
head.ErrorInfo,
sendBuffer.Length,
routeName,
(int)watch.Elapsed.TotalMilliseconds);
TraceLog.ReleaseWrite(msg);
#if DEBUG
#endif
Console.WriteLine(msg);
break;
case RequestError.Closed:
case RequestError.NotFindService:
head.ErrorInfo = ErrorNotFind;
DoWriteError(ms, head);
break;
case RequestError.UnableConnect:
head.ErrorInfo = ErrorConnected;
DoWriteError(ms, head);
break;
case RequestError.Timeout:
head.ErrorInfo = ErrorTimeout;
DoWriteError(ms, head);
break;
case RequestError.Unknown:
DoWriteError(ms, head);
break;
default:
throw new ArgumentOutOfRangeException("RequestError", error, "Not process RequestError enum.");
}
sendBuffer = ms.ReadBuffer();
return sendBuffer;
}
示例2: OnSendToClient
protected virtual void OnSendToClient(PacketMessage packet)
{
var clientAddress = packet.Head.Address;
byte[] content = packet.Content;
if (!packet.Head.EnableGzip)
{
//gzip压缩包
MessageStructure ds = new MessageStructure();
ds.WriteGzipBuffer(content);
packet.Content = ds.ReadBuffer();
}
byte[] data = packet.Content;
OnSendCompleted(clientAddress, data);
}