private bool DoSendPacket(OutPacket packet) { var stream = new MemoryStream(); var writer = new BinaryWriter(stream); writer.Write(this.dataHead); writer.Write(PacketType.CsPacketData); writer.Write(packet.Length); writer.Write(packet.Buffer, 0, packet.Length); try { _stream.Write(stream.GetBuffer(), 0, (int)stream.Length); } catch (Exception) { return(false); } return(true); }
protected void SendPacket(OutPacket packet) { _packetsToSend.Enqueue(packet); }