protected void OnStatusChange(SpawnStatus status) { if (status < SpawnStatus.None) { // If game was aborted Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateInfo("Game creation aborted")); Logs.Error("Game creation aborted"); // Hide the window gameObject.SetActive(false); } if (status == SpawnStatus.Finalized) { Request.GetFinalizationData((data, error) => { if (data == null) { Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateInfo("Failed to retrieve completion data: " + error)); Logs.Error("Failed to retrieve completion data: " + error); Request.Abort(); return; } // Completion data received OnFinalizationDataRetrieved(data); }); } }
/// <summary> /// Invoked, when user changes the value of this controller /// </summary> public virtual void OnValueChanged() { var currentValue = Dropdown.captionText.text; // Ignore if this value was change by an update, // and not by the user if (LastValue == currentValue) { return; } var loadingPromise = Msf.Events.FireWithPromise(Msf.EventNames.ShowLoading, "Updating"); Lobby.JoinedLobby.SetLobbyProperty(RawData.PropertyKey, currentValue, (successful, error) => { loadingPromise.Finish(); if (!successful) { Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateInfo(error)); Logs.Error(error); RestoreLastValue(); } }); }
public void OnFinalizationDataRetrieved(Dictionary <string, string> data) { if (!data.ContainsKey(MsfDictKeys.RoomId)) { throw new Exception("Game server finalized, but didn't include room id"); } string roomId = data[MsfDictKeys.RoomId]; Msf.Client.Rooms.GetAccess(roomId, (access, error) => { if (access == null) { Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateInfo("Failed to get access to room: " + error)); Logs.Error("Failed to get access to room: " + error); return; } OnRoomAccessReceived(access); }); if (Request != null) { Request.StatusChanged -= OnStatusChange; } }
public void OnSendCodeClick() { var email = Email.text.ToLower().Trim(); if (email.Length < 3 || !email.Contains("@")) { Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateError("Invalid e-mail address provided")); return; } var promise = Msf.Events.FireWithPromise(Msf.EventNames.ShowLoading, "Requesting reset code"); Msf.Client.Auth.RequestPasswordReset(email, (successful, error) => { promise.Finish(); if (!successful) { Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateError(error)); return; } Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateInfo( "Reset code has been sent to the provided e-mail address.")); }); }
protected void OnStatusChange(SpawnStatus status) { //We'll display the current status of the request Debug.Log(string.Format("Progress: {0}/{1} ({2})", (int)Request.Status, (int)SpawnStatus.Finalized, Request.Status)); //If game was aborted if (status < SpawnStatus.None) { Debug.Log("Game creation aborted"); return; } //Once the SpawnStatus reaches the Finalized state we can get the data from the finished request if (status == SpawnStatus.Finalized) { Request.GetFinalizationData((data, error) => { if (data == null) { Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateInfo("Failed to retrieve completion data: " + error)); Logs.Error("Failed to retrieve completion data: " + error); Request.Abort(); return; } // Completion data received OnFinalizationDataRetrieved(data); }); } }
public void OnFinalizationDataRetrieved(Dictionary <string, string> data) { if (!data.ContainsKey(MsfDictKeys.RoomId)) { throw new Exception("Game server finalized, but didn't include room id"); } var roomId = int.Parse(data[MsfDictKeys.RoomId]); var password = data.ContainsKey(MsfDictKeys.RoomPassword) ? data[MsfDictKeys.RoomPassword] : ""; Msf.Client.Rooms.GetAccess(roomId, password, (access, error) => { if (access == null) { Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateInfo("Failed to get access to room: " + error)); Logs.Error("Failed to get access to room: " + error); return; } OnRoomAccessReceived(access); }); }
protected void OnSuccess() { // Hide registration form gameObject.SetActive(false); // Show the dialog box Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateInfo("Registration successful!")); // Show the login forum Msf.Events.Fire(Msf.EventNames.RestoreLoginForm, new LoginFormData { Username = Username.text, Password = "" }); if (Msf.Client.Auth.AccountInfo != null && Msf.Client.Auth.AccountInfo.IsGuest) { Msf.Client.Auth.LogOut(); } }
public void GetAccess(int id) { Msf.Client.Rooms.GetAccess(id, (access, error) => { if (access == null) { Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateInfo("Failed to get access to room: " + error)); Logs.Error("Failed to get access to room: " + error); return; } GameObject.Find("Canvas").SetActive(false); SceneManager.LoadScene("online"); this.access = access; SceneManager.sceneLoaded += OnSceneLoaded; //StartCoroutine(WaitSceneLoaded(access)); } ); }
public void OnResetClick() { var email = Email.text.Trim().ToLower(); var code = ResetCode.text; var newPassword = Password.text; if (Password.text != PasswordRepeat.text) { Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateError("Passwords do not match")); return; } if (newPassword.Length < 3) { Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateError("Password is too short")); return; } if (string.IsNullOrEmpty(code)) { Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateError("Invalid code")); return; } if (email.Length < 3 || !email.Contains("@")) { Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateError("Invalid e-mail address provided")); return; } var data = new PasswordChangeData { Email = email, Code = code, NewPassword = newPassword }; var promise = Msf.Events.FireWithPromise(Msf.EventNames.ShowLoading, "Changing a password"); Msf.Client.Auth.ChangePassword(data, (successful, error) => { promise.Finish(); if (!successful) { Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateError(error)); return; } Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateInfo( "Password changed successfully")); Msf.Events.Fire(Msf.EventNames.RestoreLoginForm, new LoginFormData { Username = null, Password = "" }); gameObject.SetActive(false); }); }