Loading ...
Sorry, an error occurred while loading the content.

Re: [json] JSON RPC

Expand Messages
  • Lindsay
    ... I was just adding a extra attribute (object) to the RPC object, e.g. { object : S12 , method : echo , params : [ Hello JSON-RPC ], id : 1} The object
    Message 1 of 3 , Mar 12, 2006
      Michal Migurski wrote:
      > I don't think this can be resolved in the spec - it would require a
      > way to reference object in JSON, and some concept of object
      > equivalence between the client & server. A lot of apps don't have
      > this, so baking it into the spec may be overkill. Can you post your
      > workaround here? Maybe I'm misunderstanding what you mean.

      I was just adding a extra attribute (object) to the RPC object, e.g.

      { "object": "S12",
      "method": "echo", "params": ["Hello JSON-RPC"], "id": 1}

      The object value ("S12") is a ref to a object on the server which my PHP
      script would resolve to the real object, something like this:

      // object or procedure ?
      if (isset($rpc->object))
      // object call
      $obj_ses_id = "obj_" . $rpc->object;

      $obj = null;
      if (array_key_exists($obj_ses_id, $_SESSION))
      $obj = unserialize($_SESSION[$obj_ses_id]);
      if (method_exists($obj, $rpc->method))
      call_user_func_array(array(&$obj, $rpc->method), $args);
      $_SESSION[$obj_ses_id] = serialize($obj);
      BW_AddLog("object " . $rpc->method . " does not exist");
      BW_AddLog("Event for non existant object !");
      // function call
      if (function_exists($rpc->method))
      call_user_func_array($rpc->method, $args);
      BW_AddLog($rpc->method . " does not exist");

      Obviously the object ref only has meaning to my code.

      I don't think the JSONRPC spec needs to specify how a object ref works -
      that's a implementation detail, its sufficient to say the object
      attribute contains a reference to a object. After al the spec doesn't
      say how a method is resolved to a real function on the server - that's
      up to the implementation.


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.