public FREObject call(FREContext ctx, FREObject[] passedArgs) {
    String instanceId;
    FREObject responseObject = null;
    String response;

    try {
      instanceId = passedArgs[0].getAsString();

      Method method;
      PubNubWrapper instance = InstancesContainer.getInstance(instanceId);

      method = instance.getClass().getMethod(methodName());
      response = (String) method.invoke(instance);
      responseObject = FREObject.newObject(response);
    } catch (InvocationTargetException e) {
      e.printStackTrace();
      ctx.dispatchStatusEventAsync("ERROR", e.getCause().getMessage());
    } catch (Exception e) {
      e.printStackTrace();
      ctx.dispatchStatusEventAsync("ERROR", e.getMessage());
    }

    return responseObject;
  }
Esempio n. 2
0
 /** 结果传给AS端 */
 public void callBack(String status) {
   Log.d(TAG, "-----status----" + status);
   _context.dispatchStatusEventAsync(TAG, "status:" + status);
 }
Esempio n. 3
0
  public static void handleException(FREContext context, Exception e) {
    if (DEBUG_ENABLED) e.printStackTrace();

    if (context != null) context.dispatchStatusEventAsync(ExtensionEvent.ERROR, e.getMessage());
  }