public void SendPacket(TClientPacket packet) { if (isConnected) { var packetBytes = PacketConverter.ToBytes(packet); socket.Send(packetBytes); } }
public void SendMulticastPacket(TServerPacket packet) { var packetBytes = PacketConverter.ToBytes(packet); var sentBytes = udpClient.Send(packetBytes, packetBytes.Length, multicastEndPoint); if (sentBytes == 0) { /* What happens then? */ } }
protected void SendPacket(TServerPacket packet, params ClientConnection[] clientConnections) { for (int i = 0; i < clientConnections.Length; i++) { var packetBytes = PacketConverter.ToBytes(packet); var sentBytes = clientConnections[i].socket.Send(packetBytes); if (sentBytes == 0) { DisconnectClient(clientConnections[i].connectionId); Console.WriteLine("Kicked client: Peer not reachable"); } } }