Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Android plugin - Asincronous Java callback to LUA event — Gideros Forum

Android plugin - Asincronous Java callback to LUA event

achimenoachimeno Member
edited February 2013 in Plugins
Hi,
I am trying to implement an Android plugin for Skiller. When I do login, it have 2 callbacks (onResponse & onError) than I would want pass to LUA like an event. How I can do it?

Thank you,
Alex
 
			SKApplication.getInstance().login(currentActivity, 
			new SKListenerInterface<SKStatusResponse>(){
			        <a href="https://forum.giderosmobile.com/profile/Override" rel="nofollow">@Override</a>
				public void onResponse(SKStatusResponse response) {
			           // success, user logged-in 
			           //????
				}
 
				<a href="https://forum.giderosmobile.com/profile/Override" rel="nofollow">@Override</a>
				public void onError(SKStatusResponse response) {
					// failed to login 
					//????
				}
			});

Comments

  • ar2rsawseenar2rsawseen Maintainer
    edited February 2013 Accepted Answer
    nice @achimeno so how far did you progress? Can you call Java methods from Lua?
    You can look at GoogleBilling plugin as an example.

    Basically, on the Java part you can specify something like this (some rough approximation):
    public class SkillerPlugin{
        //all the stuff you have
        SKApplication.getInstance().login(currentActivity, 
    	new SKListenerInterface<SKStatusResponse>(){
    			<a href="https://forum.giderosmobile.com/profile/Override" rel="nofollow">@Override</a>
    		public void onResponse(SKStatusResponse response) {
    			// success, user logged-in 
    			//????
    		}
     
    		<a href="https://forum.giderosmobile.com/profile/Override" rel="nofollow">@Override</a>
    		public void onError(SKStatusResponse response) {
    			// failed to login 
    			//????
    		}
    	});
        //pass any data that needs to be passed here
        private static native void onResponse(String responseData);
        private static native void onError(String errorMsg);
    }
    Then in the C part you need to define:
    extern "C" {
        //your Java package here
        void Java_com_giderosmobile_android_plugins_skiller_SkillerPlugin_onError(JNIEnv *env, jclass clz, jstring errorMessage)
        {
            //now you can go to c lua bridge
        }
     
       //your Java package here
        void Java_com_giderosmobile_android_plugins_skiller_SkillerPlugin_onResponse(JNIEnv *env, jclass clz, jstring responseData)
        {
            //now you can go to c lua bridge
        }
     
     
    }
    That is just for accessing back to C, to raise a Gideros event in Lua, it's a little bit harder. You need to get ID from Gideros library and then enqueue the event, and also manage instances from which it is called.

    Hmm, let me do a tutorial on this one, hopefully this weekend, ok? :)

    Likes: achimeno

    +1 -1 (+1 / -0 )Share on Facebook
  • I'm calling Java methods from LUA, and I hope complete the plugin with this information.
    I will share my Skiller plugin with all of you when it works.

    Thank you @ar2rsawseen :)
  • fxonefxone Member
    Accepted Answer
    Hi @achimeno! why did you choose Skiller SDK? The community seems really small... What are they advantages in comparison to for example Scoreloop: http://www.scoreloop.com/developers/overview/?
  • Hi @fxone!
    Scoreloop have not multiplayer options.

    I am still looking for a multiplayer library. I found Skiller SDK, and I thank than could be easy to make a plugin. The problem is than it doesn't have iOS version.



Sign In or Register to comment.