Ejemplo n.º 1
0
        private void OnConnectionRequestReceived(Packet packet)
        {
            Monitor.Enter(clients);

            IPEndPoint remoteEP = Address.DuplicateEndPoint(packet.IPEndPoint);
            int        id       = clients.GetFirstAvailableId();

            if (id < 0 || clients.ContainsEndPoint(remoteEP))
            {
                Packet rejectedPacket = PacketFactory.GetConnectionRejected();
                trafficHandler.SendReliable(rejectedPacket, remoteEP);
            }

            ushort serverKey = Utility.GetRandomUShort();

            UDPClientHandler client =
                new UDPClientHandler(id, serverKey, packet.Key, remoteEP, this, trafficHandler);

            clients.AddTo(client, id);

            Monitor.Exit(clients);

            Packet challengePacket = PacketFactory.GetChallenge(id, serverKey);

            trafficHandler.SendReliable(challengePacket, remoteEP);
        }
Ejemplo n.º 2
0
 public void SendReliable(Packet packet)
 {
     packet.Key = CombinedKey;
     trafficHandler.SendReliable(packet, RemoteEP);
 }
Ejemplo n.º 3
0
 public void SendReliable(Packet packet)
 {
     trafficHandler.SendReliable(packet, ServerEP);
 }