public void LoggingIn() { loggingIn = true; LoginButtonText.GetComponent <TextMeshProUGUI>().fontSize = 15.0f; LoginButtonText.GetComponent <TextMeshProUGUI>().text = "Connecting..."; if (netManager) { if (netManager.IsConnectedToServer()) { netManager.AttemptLogin(UserLoginText.GetComponent <TMP_InputField>().text, PasswordText.GetComponent <TMP_InputField>().text); } } }
public bool CommandReader(string getMsg) { string usernameHolder = ""; string passwordHolder = ""; //temp plain text int passwordStartIndex = -1; if (getMsg[0] != '/') //Only process commands with '/' prefix { return(false); } if (!netManagerRef) { Debug.LogError("[Error] Network Manager reference missing! Aborting operation... "); if (bDebugToConsole) { UpdateChat("[Error] Network Manager reference missing! Aborting operation... "); } return(false); } if (getMsg == "/connect") { UpdateChat("[Console] Connecting to server... "); netManagerRef.ConnectToServer(); return(true); } if (getMsg.Length > 7) { if (getMsg.Substring(1, 6).ToLower() == "login ") { //Get username from syntax. its the first word after '/login ' for (int i = 7; i < getMsg.Length; i++) { if (getMsg[i] == ' ') { passwordStartIndex = i + 1; break; } usernameHolder = usernameHolder + getMsg[i]; } if (passwordStartIndex == -1 || passwordStartIndex > getMsg.Length) { UpdateChat("[Console] Invalid syntax."); return(false); } //Get password from syntax. its the word after the username for (int i = passwordStartIndex; i < getMsg.Length; i++) { passwordHolder = passwordHolder + getMsg[i]; } netManagerRef.AttemptLogin(usernameHolder, passwordHolder); return(true); } } if (getMsg.Length > 9) { if (getMsg.Substring(1, 9).ToLower() == "register ") { //Get username from syntax. its the first word after '/login ' for (int i = 10; i < getMsg.Length; i++) { if (getMsg[i] == ' ') { passwordStartIndex = i + 1; break; } usernameHolder = usernameHolder + getMsg[i]; } if (passwordStartIndex == -1 || passwordStartIndex >= getMsg.Length) { UpdateChat("[Console] Invalid syntax."); return(false); } //Get password from syntax. its the word after the username for (int i = passwordStartIndex; i < getMsg.Length; i++) { passwordHolder = passwordHolder + getMsg[i]; } netManagerRef.AttemptAccountCreation(usernameHolder, passwordHolder); return(true); } } if (getMsg.Length > 7) { if (getMsg.Substring(1, 6).ToLower() == "fetch ") { if (getMsg.Substring(7, 14).ToLower() == "profile ") { for (int i = 15; i < getMsg.Length; i++) { if (getMsg[i] == ' ') { passwordStartIndex = i + 1; break; } usernameHolder = usernameHolder + getMsg[i]; } netManagerRef.RequestProfileData(usernameHolder); } else if (getMsg.Substring(7, 14).ToLower() == "clientdata ") { //TODO } return(true); } } if (getMsg == "/join any" || getMsg == "/join matchmaking" || getMsg == "/join") { UpdateChat("[Console] Joining matchmaking... "); netManagerRef.QueueMatchMaking(); return(true); } if (getMsg == "/leave" || getMsg == "/leave lobby") { netManagerRef.LeaveMatchMakingQueue(); return(true); } if (getMsg == "/disconnect") { netManagerRef.Disconnect(); return(true); } Debug.Log("[Notice] Invalid Command. "); UpdateChat("[Console] Invalid Command. "); return(false); }