public byte[] ArrayBytes() { send.WriteC((byte)new Random().Next(0, 255)); BeginSend.WriteH((short)new Random().Next(0, 50000)); BeginSend.WriteH(0); BeginSend.WriteB(send.stream.ToArray()); byte[] data = Dados.Encrypt(BeginSend.stream.ToArray(), 2); // Encrypt receive.WriteH((ushort)(data.Length - 2 | 32768)); //0x8000 receive.WriteB(data); return(receive.stream.ToArray()); }
void SendThread() { new Thread(() => { while (true) { if (SendQueue.TryDequeue(out Packet data)) { Client.Send(data.Data, data.Data.Length, data.EndPoint); } else { BeginSend.Reset(); BeginSend.WaitOne(); } } }).Start(); }
internal void Enqueue(Packet data) { BeginSend.Set(); SendQueue.Enqueue(data); }