Advertisement
Guest User

Untitled

a guest
Mar 27th, 2012
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement