本文整理汇总了C#中FrameWork.PacketOut.Read方法的典型用法代码示例。如果您正苦于以下问题:C# PacketOut.Read方法的具体用法?C# PacketOut.Read怎么用?C# PacketOut.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrameWork.PacketOut
的用法示例。
在下文中一共展示了PacketOut.Read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendTCPCuted
public void SendTCPCuted(PacketOut Out)
{
long PSize = Out.Length - Out.OpcodeLen - PacketOut.SizeLen; // Size = Size-len-opcode
byte[] Packet = new byte[PSize];
Out.Position = Out.OpcodeLen + PacketOut.SizeLen;
Out.Read(Packet, 0, (int)(PSize));
List<byte> Header = new List<byte>(5);
int itemcount = 1;
while (PSize > 0x7f)
{
Header.Add((byte)((byte)(PSize) | 0x80));
PSize >>= 7;
itemcount++;
if (itemcount >= Header.Capacity + 10)
Header.Capacity += 10;
}
Header.Add((byte)(PSize));
Header.Add((byte)(Out.Opcode));
Log.Tcp("Header", Header.ToArray(), 0, Header.Count);
Log.Tcp("Packet", Packet, 0, Packet.Length);
Log.Dump("Header", Header.ToArray(), 0, Header.Count);
Log.Dump("Packet", Packet, 0, Packet.Length);
SendTCP(Header.ToArray());
SendTCP(Packet);
Out.Dispose();
}
示例2: SendSegments
public void SendSegments(PacketOut Out)
{
long PSize = Out.Length - Out.OpcodeLen - PacketOut.SizeLen; // Size = Size-len-opcode
byte[] Packet = new byte[PSize];
Out.Position = Out.OpcodeLen + PacketOut.SizeLen;
//Out.Read(Packet, 0, (int)(PSize));
List<byte> Header = new List<byte>(5);
int itemcount = 1;
while (PSize > 0x7f)
{
Header.Add((byte)((byte)(PSize) | 0x80));
PSize >>= 7;
itemcount++;
if (itemcount >= Header.Capacity + 10)
Header.Capacity += 10;
}
Header.Add((byte)(PSize));
Header.Add((byte)(Out.Opcode));
Log.Tcp("Header", Header.ToArray(), 0, Header.Count);
SendTCP(Header.ToArray());
// ugly needs to fix
byte[] buffer;
long bytesleft = PSize;
int start = 0;
while (PSize > 1460)
{
if (bytesleft < 1460) break;
buffer = new byte[(start + 1460) - start];
Out.Read(buffer, start, (start + 1460));
SendTCP(buffer);
start += 1461;
bytesleft -= 1461;
}
if (bytesleft > 0)
{
buffer = new byte[(start + bytesleft) - start];
Out.Read(buffer, start, (int)(start + bytesleft));
SendTCP(buffer);
}
}