public void Send(Packet packet) { if (tcpClient.Connected) { byte[] data = Encoding.UTF8.GetBytes(PacketEncryption.EncryptPacket(packet, password)); networkStream.Write(data, 0, data.Length); } }
private void BackgroundSender_DoWork(Packet packet, Client client) { if (client.socket.Connected) { Socket socket = client.socket; string crypted_packet = PacketEncryption.EncryptPacket(packet, password); if (!string.IsNullOrEmpty(crypted_packet)) { byte[] data = Encoding.UTF8.GetBytes(PacketEncryption.EncryptPacket(packet, password)); socket.Send(data); } } }