protected override void SendPacket(Packet.Packet packet) { if (!UdpClient.Client.Connected) { return; } UdpClient.BeginSend(packet.ToArray(), packet.Length(), _endPoint, null, null); }
/// <inheritdoc /> protected override void SendPacket(Packet.Packet packet) { if (!UdpClient.Client.Connected) { return; } UdpClient.Send(packet.ToArray(), packet.Length); }
/** * Sends a packet to all connected clients over UDP */ private void BroadcastUdp(Packet.Packet packet) { foreach (var client in _clients.Values) { // Make sure that we use a clean packet object every time var newPacket = new Packet.Packet(packet.ToArray()); // Send the newly constructed packet to the client client.SendUdp(_udpClient, newPacket); } }
/** * Sends a packet to all connected clients over TCP */ public void BroadcastTcp(Packet.Packet packet) { foreach (var idClientPair in _clients) { // Make sure that we use a clean packet object every time var newPacket = new Packet.Packet(packet.ToArray()); // Send the newly constructed packet to the client idClientPair.Value.SendTcp(newPacket); } }
/** * Sends a packet to the client with the given ID over UDP */ private void SendUdp(ushort id, Packet.Packet packet) { if (!_clients.ContainsKey(id)) { Logger.Info(this, $"Could not find ID {id} in clients, could not send UDP packet"); return; } // Make sure that we use a clean packet object every time var newPacket = new Packet.Packet(packet.ToArray()); // Send the newly constructed packet to the client _clients[id].SendUdp(_udpClient, newPacket); }
public void Send(Packet.Packet packet) { if (UdpClient?.Client == null) { return; } if (!UdpClient.Client.Connected) { Logger.Get().Error(this, "Tried sending packet, but UDP was not connected"); return; } // Send the packet UdpClient.BeginSend(packet.ToArray(), packet.Length(), null, null); }
/** * Sends a packet over UDP to this specific client */ public void SendUdp(UdpClient udpClient, Packet.Packet packet) { udpClient.BeginSend(packet.ToArray(), packet.Length(), _endPoint, null, null); }
/// <inheritdoc /> protected override void SendPacket(Packet.Packet packet) { UdpClient.Send(packet.ToArray(), packet.Length, _endPoint); }