From b71e9a5b0abf1b72d1e3d96cea3bf2dc79e2454b Mon Sep 17 00:00:00 2001 From: joon Date: Thu, 30 Jan 2014 21:26:27 +0100 Subject: [PATCH 1/2] Added Gamer Info / username --- src/IAPHandler.hx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/IAPHandler.hx b/src/IAPHandler.hx index 13b9d69..bfd3a71 100644 --- a/src/IAPHandler.hx +++ b/src/IAPHandler.hx @@ -20,6 +20,7 @@ class IAPHandler public var requestProductListCall:Dynamic; public var getProductListIDsCall:Dynamic; public var requestReceiptsCall:Dynamic; + public var requestGamerInfoCall:Dynamic; public var getReceiptProductIDsCall:Dynamic; public var requestPurchaseCall:Dynamic; public var getLastPurchasedProductIDCall:Dynamic; @@ -35,6 +36,8 @@ class IAPHandler trace("=================== JNI linking methods..."); initCall = openfl.utils.JNI.createStaticMethod ("com.jarnik.iaptest.OUYA_IAP", "init", "(Lorg/haxe/lime/HaxeObject;Ltv/ouya/console/api/OuyaFacade;Ljava/lang/String;)V", true); + requestGamerInfoCall = openfl.utils.JNI.createStaticMethod + ("com.jarnik.iaptest.OUYA_IAP", "requestGamerInfo", "()V", true); requestProductListCall = openfl.utils.JNI.createStaticMethod ("com.jarnik.iaptest.OUYA_IAP", "requestProductList", "([Ljava/lang/String;)V", true); getProductListIDsCall = openfl.utils.JNI.createStaticMethod @@ -89,6 +92,22 @@ class IAPHandler // ==================================== CALLBACKS - OVERRIDE THESE! ======================= + // === get username + public function onGamerInfoReceived(username:String) + { + trace("=== onGamerInfoReceived! " + username); + } + + public function onGamerInfoFailed(error:String) + { + trace("=== onGamerInfoFailed! " + error); + } + + public function onGamerInfoCanceled() + { + trace("=== onGamerInfoCanceled! " ); + } + // ==== Product List public function onProductListReceived() { From af4795b052db4378763a141c9710f6e4dbd3da32 Mon Sep 17 00:00:00 2001 From: joon Date: Thu, 30 Jan 2014 21:28:09 +0100 Subject: [PATCH 2/2] Added relevant code in the java file for GamerInfo --- src/java/com/jarnik/iaptest/OUYA_IAP.java | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/java/com/jarnik/iaptest/OUYA_IAP.java b/src/java/com/jarnik/iaptest/OUYA_IAP.java index af65e6b..31dd6bb 100644 --- a/src/java/com/jarnik/iaptest/OUYA_IAP.java +++ b/src/java/com/jarnik/iaptest/OUYA_IAP.java @@ -64,7 +64,31 @@ public static void init(final HaxeObject callback, OuyaFacade ouyaFacade, String Log.e("IAP", "Unable to create encryption key", e); } } + // ======================================== GAMER INFO ====================================== + public static void requestGamerInfo() + { + mOuyaFacade.requestGamerInfo(new GamerInfoLister()); + } + public static class GamerInfoLister implements OuyaResponseListener + { + @Override + public void onSuccess(GamerInfo gamerInfoResponse) { + mCallback.call("onGamerInfoReceived", new Object[] { gamerInfoResponse.getUsername() } ); + } + + @Override + public void onFailure(int errorCode, String errorMessage, Bundle optionalData) { + mCallback.call("onGamerInfoFailed", new Object[] { errorCode+": "+errorMessage } ); + } + + @Override + public void onCancel() { + mCallback.call("onGamerInfoCanceled", new Object[] {} ); + } + } + + // ======================================= PRODUCT LIST ===================================================== public static void requestProductList(String[] products)