Exemple #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);
        }
Exemple #2
0
        private void OnChallengeResponseReceived(Packet packet)
        {
            UDPClientHandler client = clients.Get(packet.IPEndPoint);

            if (client == null)
            {
            }
            else
            {
            }
        }