Esempio n. 1
0
        // -------------------------------------------------------------------------------
        // RequestUserRegister
        // @Client
        // -------------------------------------------------------------------------------
        protected override bool RequestUserRegister(NetworkConnection conn, string name, string password, string usermail)
        {
            if (!base.RequestUserRegister(conn, name, password, usermail))
            {
                return(false);
            }

            ClientMessageRequestUserRegister message = new ClientMessageRequestUserRegister
            {
                username = name,
                password = GenerateHash(name, password),
                email    = usermail,
                deviceid = Tools.GetDeviceId
            };

            conn.Send(message);

            return(true);
        }
Esempio n. 2
0
        // -------------------------------------------------------------------------------
        // OnClientMessageRequestUserRegister
        // @Client -> @Server
        // -------------------------------------------------------------------------------
        void OnClientMessageRequestUserRegister(NetworkConnection conn, ClientMessageRequestUserRegister msg)
        {
            ServerMessageResponseUserRegister message = new ServerMessageResponseUserRegister
            {
                success          = true,
                text             = "",
                causesDisconnect = false
            };

            if (DatabaseManager.singleton.TryUserRegister(msg.username, msg.password, msg.email, msg.deviceid))
            {
                DatabaseManager.singleton.SaveDataUser(msg.username, false);
                message.text = systemText.userRegisterSuccess;
            }
            else
            {
                message.text    = systemText.userRegisterFailure;
                message.success = false;
            }

            conn.Send(message);
        }