Exemplo n.º 1
0
 public void SendPacket(TClientPacket packet)
 {
     if (isConnected)
     {
         var packetBytes = PacketConverter.ToBytes(packet);
         socket.Send(packetBytes);
     }
 }
Exemplo n.º 2
0
        public void SendMulticastPacket(TServerPacket packet)
        {
            var packetBytes = PacketConverter.ToBytes(packet);
            var sentBytes   = udpClient.Send(packetBytes, packetBytes.Length, multicastEndPoint);

            if (sentBytes == 0)
            { /* What happens then? */
            }
        }
Exemplo n.º 3
0
        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");
                }
            }
        }