Example #1
0
    public RegisterReplyMessage addUser(RegisterMessage message, UserInfo user)
    {
        RegisterReplyMessage replyMessage = new RegisterReplyMessage(message);

        if (manager.database.conn.KeyExists("usernames:" + user.username))
        {
            replyMessage.reply = RegisterReplyMessage.registerReply.USEREXISTS;
            return(replyMessage);
        }

        string id = Guid.NewGuid().ToString();

        HashEntry[] entries =
        {
            new HashEntry("id",          id),
            new HashEntry("username",    user.username),
            new HashEntry("password",    user.password),
            new HashEntry("permissions", (int)user.permissions)
        };
        manager.database.conn.HashSet("user:"******"username", user.username),
            new HashEntry("id",       id)
        };
        manager.database.conn.HashSet("usernames:" + user.username, entries2);

        replyMessage.reply = RegisterReplyMessage.registerReply.SUCCESS;
        replyMessage.user  = user;
        return(replyMessage);
    }
Example #2
0
    public void register()
    {
        RegisterMessage message = new RegisterMessage();

        message.username    = username.text;
        message.password    = password.text;
        message.onResponse += (QTResponsableMessage message) => {
            RegisterReplyMessage reply = (RegisterReplyMessage)message;

            Debug.Log("Registered with ID - " + reply.user.id);
        };

        ClientManager.instance.masterClient.sendMessage(message);
    }
Example #3
0
    public override void handleMessage(QTMessage message)
    {
        switch (message.messageType)
        {
        case QTMessage.type.REGISTER:
            RegisterMessage registerMessage = (RegisterMessage)message;
            UserInfo        info            = new UserInfo();
            info.username    = registerMessage.username;
            info.password    = registerMessage.password;
            info.permissions = UserInfo.userPermissions.USER;

            RegisterReplyMessage replyMessage = MasterServerManager.instance.authManager.addUser(registerMessage, info);
            client.sendMessage(replyMessage);
            break;

        case QTMessage.type.LOGIN:
            LoginMessage loginMessage = (LoginMessage)message;

            LoginReplyMessage loginReplyMessage = MasterServerManager.instance.authManager.loginUser(loginMessage);
            client.sendMessage(loginReplyMessage);
            break;
        }
    }