本文整理汇总了C#中IConnection.PushPacket方法的典型用法代码示例。如果您正苦于以下问题:C# IConnection.PushPacket方法的具体用法?C# IConnection.PushPacket怎么用?C# IConnection.PushPacket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConnection
的用法示例。
在下文中一共展示了IConnection.PushPacket方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Send
public void Send(IConnection state)
{
if (state == null || !state.IsValid)
return;
if (!OuterNetworkOpcode.Send.ContainsKey(GetType()))
{
Log.Warn("UNKNOWN packet opcode: {0}", GetType().Name);
return;
}
lock (WriteLock)
{
if (Data == null)
{
try
{
using (MemoryStream stream = new MemoryStream())
{
using (BinaryWriter writer = new BinaryWriter(stream, new UTF8Encoding()))
{
WriteH(writer, OuterNetworkOpcode.Send[GetType()]);
WriteH(writer, 0); //Reserved for length
Write(writer);
}
Data = stream.ToArray();
BitConverter.GetBytes((short)Data.Length).CopyTo(Data, 2);
}
}
catch (Exception ex)
{
Log.Warn("Can't write packet: {0}", GetType().Name);
Log.WarnException("ASendPacket", ex);
return;
}
}
}
//Log.Warn("PUSH packet opcode: {0}", GetType().Name);
//Log.Debug("Data:\n{0}", Data.FormatHex());
state.PushPacket(Data);
}
示例2: Send
public void Send(IConnection state)
{
if (state == null || !state.IsValid)
{ return; }
if (!OpCodes.Send.ContainsKey(GetType()))
{
Logger.WriteLine(LogState.Warn,"UNKNOWN packet opcode: {0}", GetType().Name);
return;
}
lock (WriteLock)
{
if (Datas == null)
{
try
{
using (MemoryStream stream = new MemoryStream())
{
using (BinaryWriter writer = new BinaryWriter(stream, new UTF8Encoding()))
{
WriteWord(writer, 0); //Reserved for length
WriteWord(writer, OpCodes.Send[GetType()]);
Write(writer);
}
Datas = stream.ToArray();
BitConverter.GetBytes((short) Datas.Length).CopyTo(Datas, 0);
Logger.WriteLine(LogState.Debug, "S->C Packet Data:\n{0}", Datas.FormatHex());
}
}
catch (Exception ex)
{
Logger.WriteLine(LogState.Warn,"Can't write packet: {0}", GetType().Name);
Logger.WriteLine(LogState.Warn, "ASendPacket" + ex);
return;
}
}
}
state.PushPacket(Datas);
}
示例3: Send
public void Send(IConnection state)
{
Log.Debug("SendPacket Data:\n{0}", Data.FormatHex());
state.PushPacket(Data);
}
示例4: Send
public void Send(IConnection state)
{
state.PushPacket(Data);
}
示例5: Send
public void Send(IConnection state)
{
Logger.WriteLine(LogState.Debug,"SendPacket Data:\n{0}", Data.FormatHex());
state.PushPacket(Data);
}
示例6: Send
public void Send(IConnection state)
{
if (state == null || !state.IsValid)
return;
State = (OuterNetworkConnection)state;
if (GetType() != typeof(SpTest) && !OuterNetworkOpcode.Send.ContainsKey(GetType()))
{
Log.Warn("UNKNOWN packet opcode: {0}", GetType().Name);
return;
}
lock (WriteLock)
{
if (Datas == null)
{
try
{
using (MemoryStream stream = new MemoryStream())
{
int lengthoffset = 6;
using (BinaryWriter writer = new BinaryWriter(stream))
{
WriteH(writer, 0); //Reserved for packet length
switch (WorldServer.CountryCode)
{
case CountryCode.CN:
{
WriteC(writer, 0);
lengthoffset = 7;
}
break;
case CountryCode.EN:
{
lengthoffset = 6;
}
break;
case CountryCode.TH:
{
lengthoffset = 6;
}
break;
case CountryCode.TW:
{
WriteC(writer, 0);
lengthoffset = 7;
}
break;
}
WriteH(writer, State.UID);
WriteH(writer, (GetType() != typeof(SpTest)) ? OuterNetworkOpcode.Send[GetType()] : 0);
WriteH(writer, 0); //Reserved for data length
Write(writer);
}
Datas = stream.ToArray();
BitConverter.GetBytes((short)(Datas.Length - 2)).CopyTo(Datas, 0);
BitConverter.GetBytes((short)(Datas.Length - 8)).CopyTo(Datas, lengthoffset);
//Log.Debug("Send Data {0}: [{1}] {2}", GetType().Name, Datas.Length, Datas.FormatHex());
WriteScope(ref Datas);
}
}
catch (Exception ex)
{
Log.Warn("Can't write packet: {0}", GetType().Name);
Log.WarnException("ASendPacket", ex);
return;
}
}
}
state.PushPacket(Datas);
}