예제 #1
0
    // HANDLERS

    /**
     * <summary> Déclenché lorsqu'une requête d'authentification est reçue. </summary>
     */
    void OnAuthentificationRequest(BloodAndBileEngine.Networking.NetworkMessageInfo info, AuthentificationMessage message)
    {
        if (message.AuthType != AuthentificationType.MATCH_SERVER)
        {
            return;                                                        // Si le type d'authentification n'est pas "Match_Server", on ne fait rien.
        }
        // On vérifie que cette IP ne soit pas déjà occupée.
        string IP;

        if (message.IP == "")
        {
            IP = NetworkSocket.GetConnectionInfoFromConnectionID(info.ConnectionID).IP.Split(':')[3];
        }
        else
        {
            IP = message.IP;
        }

        BloodAndBileEngine.Debugger.Log("Tentative de connexion d'un Match Server avec l'IP " + IP);

        if (MatchServerIPs.ContainsKey(info.ConnectionID))
        {
            BloodAndBileEngine.Debugger.Log("ERREUR - Cette ID de connexion est déjà occupée !", Color.red);
            SendAuthentificationResponse(false, "ID de connexion déjà prit !", info.ConnectionID);
        }
        else if (MatchServerIPs.ContainsValue(IP))
        {
            BloodAndBileEngine.Debugger.Log("ERREUR - Cette IP est déjà répertoriée !", Color.red);
            SendAuthentificationResponse(false, "IP déjà prise !", info.ConnectionID);
        }
        else if (message.Password == MatchServerPassword)
        {
            MatchServerIPs.Add(info.ConnectionID, IP);
            BloodAndBileEngine.Debugger.Log("Ajout d'un Match Server : " + IP);
            SendAuthentificationResponse(true, "", info.ConnectionID);
        }
    }