Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 27th, 2012  |  syntax: None  |  size: 1.00 KB  |  views: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // hoffentlich lan mi da nid zwiit uf d'äscht use :D
  2.  
  3. private JSONObject dispatch(int id, String methodName, JSONArray params) throws JSONException {
  4.     Method m = null;
  5.     JSONObject result = null;
  6.     Throwable t = null;
  7.     String errorMsg = "RPC Error";
  8.  
  9.     try {
  10.         m = mReceiver.getClass().getMethod(methodName, new Class[] { JSONArray.class });
  11.         if (!m.isAnnotationPresent(Rpc.class)) {
  12.             errorMsg = "Method exists but is no Rpc.class representant";
  13.         }
  14.         else {
  15.             result = (JSONObject) m.invoke(mReceiver, new Object[] { params });
  16.         }
  17.     }        
  18.     catch (NoSuchMethodException e) {
  19.         // handle or not?
  20.         t = e;
  21.     }        
  22.     catch (SecurityException e2) {
  23.          // handle or not?
  24.         t = e2;
  25.     }        
  26.  
  27.     if (result == null) {
  28.         result = JsonRpcResult.error(errorMsg, t);
  29.     }
  30.      
  31.     result.put("id", id);
  32.     Log.v(TAG, "Sending reply " + result.toString());
  33.     return result;
  34. }
clone this paste RAW Paste Data