// ------------------------------------------------------------------------------- // OnClientMessageRequestUserDelete // @Client -> @Server // ------------------------------------------------------------------------------- /// <summary> /// Event <c>OnClientMessageRequestUserDelete</c>. /// Triggered when the server receives a user deletion request. /// </summary> /// <param name="conn"></param> /// <param name="msg"></param> void OnClientMessageRequestUserDelete(NetworkConnection conn, ClientMessageRequestUserDelete msg) { ServerMessageResponseUserDelete message = new ServerMessageResponseUserDelete { success = true, text = "", causesDisconnect = false }; if (!GetIsUserLoggedIn(msg.userName) && DatabaseManager.singleton.TryUserDelete(msg.userName, msg.password)) { message.text = systemText.userDeleteSuccess; debug.LogFormat(this.name, nameof(OnClientMessageRequestUserDelete), conn.ID(), "Success"); //DEBUG } else { message.text = systemText.userDeleteFailed; message.success = false; debug.LogFormat(this.name, nameof(OnClientMessageRequestUserDelete), conn.ID(), "DENIED"); //DEBUG } conn.Send(message); }
// ------------------------------------------------------------------------------- // RequestUserDelete // @Client // ------------------------------------------------------------------------------- /// <summary> /// Protected override function <c>RequestUserDelete</c> that returns a boolean. /// Sends a user deletion request to the server. /// Checks whether the user deletion request is valid and can be sent to the server. /// Returns a boolean detailing whether the request was sent or not. /// </summary> /// <param name="conn"></param> /// <param name="userName"></param> /// <param name="password"></param> /// <param name="action"></param> /// <returns> Returns a boolean detailing whether the request was sent to the server. </returns> protected override bool RequestUserDelete(NetworkConnection conn, string userName, string password, int action = 1) { if (!base.RequestUserDelete(conn, userName, password)) { return(false); } ClientMessageRequestUserDelete message = new ClientMessageRequestUserDelete { username = userName, password = Tools.GenerateHash(name, password) }; conn.Send(message); debug.LogFormat(this.name, nameof(RequestUserDelete), conn.Id(), userName); //DEBUG return(true); }