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)); socket.Send(Header.ToArray()); socket.Send(Packet); Out.Dispose(); }
public void SendTCPCuted(PacketOut outPacket) { long pSize = outPacket.Length - outPacket.OpcodeLen - PacketOut.SizeLen; // Size = Size-len-opcode byte[] packet = new byte[pSize]; outPacket.Position = outPacket.OpcodeLen + PacketOut.SizeLen; outPacket.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)(outPacket.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); outPacket.Dispose(); }