Notifications
Clear all

Register CB Handlers in Javascript

(@maroku)
Active Member Registered

Using combu with Javascript works fine at the moment but i have a little problem now.
I am not able to register CB handlers with Javascript because i dont know how to.

i would like if i use (CBManager.instance.Login) that this calls the function OnUserLogin after succesfull login.

Is it even possible in Javascript?
if yes, how i would do it?

PS: I use Unity

ReplyQuote
Topic starter Posted : 07/05/2013 6:09 pm
(@skaredcreations)
Prominent Member Admin

Here is an example of delegates usage in UnityScript:

#pragma strict

function Start () {
	var cbManager : CBManager = FindObjectOfType(CBManager);
	cbManager.OnLogin = OnUserLogin;
	cbManager.Login("my_username", "my_password");
}

function OnUserLogin (user : CBUser, error : String) {
	if (user)
		print("User logged in: " + user.username);
	else
		print("Login failed");
}

FRANCESCO CROCETTI @ SKARED CREATIONS

ReplyQuote
Posted : 07/05/2013 7:30 pm
(@maroku)
Active Member Registered

Thank you it works!

PS: sorry for the e-mail with the same question. i will use the forum if i have any questions for now.

ReplyQuote
Topic starter Posted : 07/05/2013 7:48 pm
Share: