private void Start() { cotcGO.GetCloud() .Catch(retry => { Debug.LogError("Can't connect to the cloud"); }) .Done(_cloud => { cloud = _cloud; Profile.StartLogin(); SetupHttpHandler(); }); }
/// <summary> /// Get the CotcSdk's Cloud instance. /// </summary> /// <param name="cotcGameObject">CotcSdk's CotcGameObject instance.</param> /// <param name="OnSuccess">The callback in case of request success.</param> /// <param name="OnError">The callback in case of request error.</param> public static void Backend_GetCloud(CotcGameObject cotcGameObject, Action <Cloud> OnSuccess = null, Action <ExceptionError> OnError = null) { // Call the API method which returns a Cloud result cotcGameObject.GetCloud() // Result if everything went well .Done(delegate(Cloud cloudInstance) { DebugLogs.LogVerbose("[CotcSdkTemplate:CloudFeatures] GetCloud success"); // Keep the Cloud instance reference cloud = cloudInstance; // Register to the HttpRequestFailedHandler event cloud.HttpRequestFailedHandler = RetryFailedRequestOnce; // Call the OnSuccess action if any callback registered to it if (OnSuccess != null) { OnSuccess(cloudInstance); } // Call the CloudInitialized event if any callback registered to it if (Event_CloudInitialized != null) { Event_CloudInitialized(cloud); } }, // Result if an error occured delegate(Exception exception) { // Call the OnError action if any callback registered to it if (OnError != null) { OnError(ExceptionTools.GetExceptionError(exception)); } // Else, log the error (expected to be a CotcException) else { ExceptionTools.LogCotcException("CloudFeatures", "GetCloud", exception); } }); }
public void OnEmailConnexionClick() { CotcGameObject cotc = FindObjectOfType <CotcGameObject>(); string email = GameObject.Find("Email").GetComponent <InputField>().text; string mdp = GameObject.Find("MotDePasse").GetComponent <InputField>().text; cotc.GetCloud().Done(cloud => { cloud.Login( network: "email", networkId: email, networkSecret: mdp) .Done(gamer => { Player = gamer; Debug.Log("Signed in succeeded (ID = " + gamer.GamerId + ")"); Debug.Log("Login data: " + gamer); Debug.Log("Server time: " + gamer["servertime"]); connectedWithAccount = true; GuiControl.OnReturnClick(); }, ex => { // The exception should always be CotcException CotcException error = (CotcException)ex; if (error.ServerData["name"] == "BadArgument") { GameObject.Find("Error").GetComponent <Text>().text = "Erreur, l'adresse e-mail ou le mot de passe n'est pas valide."; } else if (error.ServerData["name"] == "BadUserCredentials") { GameObject.Find("Error").GetComponent <Text>().text = "Erreur, le mot de passe n'est pas correcte."; } else { GameObject.Find("Error").GetComponent <Text>().text = "Erreur."; } }); }); }
public void AnonymeConnexion() { CotcGameObject cotc = FindObjectOfType <CotcGameObject>(); cotc.GetCloud().Done(cloud => { cloud.LoginAnonymously() .Done(gamer => { Debug.Log("Signed in succeeded (ID = " + gamer.GamerId + ")"); Debug.Log("Signed in succeeded (Secret = " + gamer.GamerSecret + ")"); Debug.Log("Login data: " + gamer); Debug.Log("Server time: " + gamer["servertime"]); connected = true; Player = gamer; SetUserValue("MaxScore", new Bundle(0)); }, ex => { // The exception should always be CotcException CotcException error = (CotcException)ex; Debug.LogError("Failed to login: "******" (" + error.HttpStatusCode + ")"); }); }); }
// Start is called before the first frame update void Start() { cb = CotcSdk.GetComponent <CotcGameObject>(); cb.GetCloud().Done(cloud => { Cloud = cloud; }); }