public void onMessage(JSONObject msg, Callback cb) {
        // TODO call the callback obj in case of callback. If not send call the
        // method!
        String methodName = msg.optString("method", null);
        JSONObject data = msg.optJSONObject("data");
        if (methodName == null) {
            System.err.println("No method in reqest");
        }

        java.lang.reflect.Method method = null;
        try {
            method = this.getClass().getMethod(methodName, JSONObject.class, Callback.class);
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            System.err.println("Invalid method : " + methodName);
            e.printStackTrace();
        }
        if (method != null) {
            try {
                method.invoke(this, data, cb);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }
        }
    }