- Home /
Beginners question with Unity and App42 - Struggling with handling call back on exception
Hi,
The code below is a simple example. I'm tried several ways to handle the exception and none seem to be working. In the example below, the callBack variable returns no data. Sorry for the beginner's question, but what I'm I missing??
using UnityEngine; using System.Collections; using System; using com.shephertz.app42.paas.sdk.csharp; using com.shephertz.app42.paas.sdk.csharp.user;
public class UserTest : MonoBehaviour { private const string app42AppKey = "AppKey"; private const string app42SecretKey = "";
public string success;
private UserService userService;
UserResponse callBack = new UserResponse();
// Use this for initialization
void Start () {
Debug.Log ("API Called");
App42API.Initialize(app42AppKey,app42SecretKey);
String userName = "<User>";
String pwd = "********";
String emailId = "<Email>";
userService = App42API.BuildUserService();
userService.CreateUser(userName, pwd, emailId, callBack);
success = callBack.getResult ();
Debug.Log (success);
}
}
using UnityEngine; using System; using System.Collections; using com.shephertz.app42.paas.sdk.csharp; using com.shephertz.app42.paas.sdk.csharp.user;
public class UserResponse : App42CallBack {
private string result = "";
public void OnSuccess (object response) {
User user = (User) response;
result = user.ToString ();
Debug.Log("userName is " + user.GetUserName());
Debug.Log("emailId is " + user.GetEmail());
}
public void OnException(Exception e) {
result = e.ToString ();
Debug.Log("Exception : " + e);
}
public string getResult() {
return result;
}
}
I figured this out. The response occurs after I check for it. I had to implement a WaitForResponse routine to handle the result.
Your answer
Follow this Question
Related Questions
Expanded explanation on Time.time? 1 Answer
Android API Level < 9 1 Answer
How do I send data to a cloud server like Amazon EC2? 1 Answer
Access to Microsoft Active Accessibility API? 1 Answer
Coroutine for WWW call not resuming 0 Answers