// ------------------------------------------------------------------------------- // OnClientMessageRequestPlayerRegister // @Client -> @Server // ------------------------------------------------------------------------------- /// <summary> /// Event <c>OnClientMessageRequestPlayerRegister</c>. /// Triggered by the server receiving a player regstration request from the client. /// </summary> /// <param name="conn"></param> /// <param name="msg"></param> void OnClientMessageRequestPlayerRegister(NetworkConnection conn, ClientMessageRequestPlayerRegister msg) { ServerMessageResponsePlayerRegister message = new ServerMessageResponsePlayerRegister { success = true, text = "", causesDisconnect = false, playername = msg.playername }; if (DatabaseManager.singleton.TryPlayerRegister(msg.playername, msg.username, msg.prefabname)) { RegisterPlayer(msg.username, msg.playername, msg.prefabname); message.text = systemText.playerRegisterSuccess; } else { message.text = systemText.playerRegisterFailure; message.success = false; debug.LogFormat(this.name, nameof(OnClientMessageRequestPlayerRegister), conn.Id(), "DENIED"); //DEBUG } conn.Send(message); }
// ------------------------------------------------------------------------------- // RequestPlayerRegister // @Client // ------------------------------------------------------------------------------- protected override bool RequestPlayerRegister(NetworkConnection conn, string playerName, string userName, string prefabName) { if (!base.RequestPlayerRegister(conn, playerName, userName, prefabName)) { return(false); } ClientMessageRequestPlayerRegister message = new ClientMessageRequestPlayerRegister { playername = playerName, username = userName, prefabname = prefabName }; conn.Send(message); return(true); }
// ------------------------------------------------------------------------------- // RequestPlayerRegister // @Client // ------------------------------------------------------------------------------- /// <summary> /// Protected override function <c>RequestPlayerRegister</c> that returns a boolean. /// Sends a player register request to the server. /// Checks whether the player register 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="playerName"></param> /// <param name="userName"></param> /// <param name="prefabName"></param> /// <returns> Returns a boolean detailing whether the request was sent to the server. </returns> protected override bool RequestPlayerRegister(NetworkConnection conn, string playerName, string userName, string prefabName) { if (!base.RequestPlayerRegister(conn, playerName, userName, prefabName)) { return(false); } ClientMessageRequestPlayerRegister message = new ClientMessageRequestPlayerRegister { playername = playerName, username = userName, prefabname = prefabName }; conn.Send(message); debug.LogFormat(this.name, nameof(RequestPlayerRegister), conn.Id(), playerName, prefabName); //DEBUG return(true); }
// ------------------------------------------------------------------------------- // OnClientMessageRequestPlayerRegister // @Client -> @Server // ------------------------------------------------------------------------------- void OnClientMessageRequestPlayerRegister(NetworkConnection conn, ClientMessageRequestPlayerRegister msg) { ServerMessageResponsePlayerRegister message = new ServerMessageResponsePlayerRegister { success = true, text = "", causesDisconnect = false }; if (DatabaseManager.singleton.TryPlayerRegister(msg.playername, msg.username, msg.prefabname)) { RegisterPlayer(msg.username, msg.playername, msg.prefabname); message.text = systemText.playerRegisterSuccess; } else { message.text = systemText.playerRegisterFailure; message.success = false; } conn.Send(message); }