public void SendPacket(Packet packet)
{
lock (SyncSend)
{
if (Sock.Connected)
{
try
{
byte[] data = packet.GetFullData();
Sock.Send(data, data.Length, SocketFlags.None);
packet.timeSent = new TimeSpan(DateTime.UtcNow.Ticks).TotalMilliseconds;
log.Log(packet, false);
if (onPacketSendListeners != null) onPacketSendListeners(packet);
if (confirmPackets)
{
if (packet.GetHeader() != Headers.PACKET_RECEIVED)
this.packetProcessor.SentPacket(packet, this);
}
// Console.Out.WriteLine("Sent a packet with header " + packet.GetHeader() + " and ID " + packet.GetPacketID());
}
catch (Exception ex)
{
Show("Unable to sent a packet.");
Show(ex);
}
}
else
Show("Fail. You shouldn't be able to make it send a packet, without having a connection.");
}
}