Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // hoffentlich lan mi da nid zwiit uf d'äscht use :D
- private JSONObject dispatch(int id, String methodName, JSONArray params) throws JSONException {
- Method m = null;
- JSONObject result = null;
- Throwable t = null;
- String errorMsg = "RPC Error";
- try {
- m = mReceiver.getClass().getMethod(methodName, new Class[] { JSONArray.class });
- if (!m.isAnnotationPresent(Rpc.class)) {
- errorMsg = "Method exists but is no Rpc.class representant";
- }
- else {
- result = (JSONObject) m.invoke(mReceiver, new Object[] { params });
- }
- }
- catch (NoSuchMethodException e) {
- // handle or not?
- t = e;
- }
- catch (SecurityException e2) {
- // handle or not?
- t = e2;
- }
- if (result == null) {
- result = JsonRpcResult.error(errorMsg, t);
- }
- result.put("id", id);
- Log.v(TAG, "Sending reply " + result.toString());
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement