{"id":25470183,"url":"https://github.com/thinkphp/json-rpc-mootools","last_synced_at":"2025-07-14T12:42:45.959Z","repository":{"id":1224573,"uuid":"1152463","full_name":"thinkphp/JSON-RPC-MooTools","owner":"thinkphp","description":"Implementation of the JSON-RPC 1.1 protocol client in MooTools.","archived":false,"fork":false,"pushed_at":"2010-12-09T16:39:20.000Z","size":100,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-14T14:54:26.291Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://thinkphp.ro/apps/js-hacks/JSONRPC/jsonrpc.html","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thinkphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-12-09T08:48:15.000Z","updated_at":"2014-01-15T01:07:28.000Z","dependencies_parsed_at":"2022-07-18T16:28:55.686Z","dependency_job_id":null,"html_url":"https://github.com/thinkphp/JSON-RPC-MooTools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2FJSON-RPC-MooTools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2FJSON-RPC-MooTools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2FJSON-RPC-MooTools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2FJSON-RPC-MooTools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thinkphp","download_url":"https://codeload.github.com/thinkphp/JSON-RPC-MooTools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239437266,"owners_count":19638457,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-18T08:32:15.387Z","updated_at":"2025-02-18T08:32:15.982Z","avatar_url":"https://github.com/thinkphp.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Plugin JSONRPC - Implementation of the JSON-RPC protocol client in MooTools\n---------------------------------------------------------------------------\n\nJSON-RPC is a lightweight remote procedure call protocol similar to ``XML-RPC``.It's designed to be simple!\nThe general mechanism consists of two peers establishing a data connection. During the lifetime of a connection, peers invoke methods provided by the othe peer. To invoke a remote method, o request is sent.\n\nThis plugin implements the ``JSONRPC`` class with a ``send`` function can be used for performing [JSON-RPC](http://json-rpc.org/) calls.\n\nJSON-RPC Specifications: [http://json-rpc.org/wiki/specification](http://json-rpc.org/wiki/specification)\n\n\n## How to Use:\n \nThe JSON-RPC setup has two parts: configuration and call.\n\n      var myClientRPC = new JSONRPC({\n          url: 'path2server',\n          methodname: 'bubblesort',\n          onSuccess: function(resp) {\n                console.log(resp.result);\n          }   \n      });\n\nThe above code creates a client JSON-RPC object, that is bound to remote ``bubblesort`` method. This binding allows us to call the remote method passing only parameters and callback, without repeating the method multiple times:\n\n       myClientRPC.send({params: [9,8,7,6,5,4,3,2,1], \n           onSuccess: function(resp){\n                 if(window.console) {console.log(resp.result);}\n           }\n       }); \n\n### Options:\n\nOptions for JSON-RPC configuration are as follows:\n\n* ``url`` (*String*) The URL of the JSON-RPC service. Defaults to ``/``.\n* ``methodname`` (*String*) The name of the remote method. Defaults to ``null``. This option is not required, it can be specified later using ``send`` method.\n* ``params`` (*Array*) or (*Object*) Either a vector of parameters, or an object containing the parameters that will be passed to the remote method. This options is optional (not mandatory).\n* ``encoding`` (*String*) Encoding scheme. It is passed through to ``Request.JSON``. \n* ``headers`` (*String*) Request headers. Passed through to ``Request.JSON``.\n\n### Events:\n\nThe JSONRPC class has four events and you can specify the matching callbacks.\n\n* ``success`` | ``onSuccess`` (*Function*) this event is fired when the JSON-RPC call is finished, and the ID is returned from the server matches the one used in the request.\n* ``failure`` | ``onFailure`` (*Function*) this event is fired when the HTTP request fails. This event does not signify that the actual RPC call failed. For the RPC failure use the ``idMismatch`` and ``remoteFailure``.\n* ``remoteFailure`` | ``onRemoteFailure`` (*Function*) this event is fired when the remote method raises an exception. Only the ``error`` key of the complete response  is returned.\n* ``idMismatch`` | ``onIdMismatch``(*Function*) this event is fired when the JSON-RPC ID returned by the server does not match the one sent by client JSONRPC call. Thus, the complete ``response`` object is passed to the callback function, it would probably by unwise to treat it as safe.\n\n\n### Sending requests:\n\nYou send JSON-RPC requests using ``send`` method. This function takes a single object as argument. If any of the object properties matches the one specified in the configuration, it will override the \nconfiguration. The object can have the following properties:\n\n* ``method`` (*String*) the remote method name.\n* ``params`` (*Array*) or (*Object*) parameters to pass to remote method.\n* ``id`` (*String*) or (*int*) or (*mixed*) the JSON-RPC unique ID.\n* ``onSuccess`` (*Function*) this event is fired when the JSON-RPC call is finished, and the ID is returned from the server matches the one used in the request.\n* ``onFailure`` (*Function*) this event is fired when the HTTP request fails. This event does not signify that the actual RPC call failed. For the RPC failure use the ``idMismatch`` and ``remoteFailure``.\n* ``onRemoteFailure`` (*Function*) this event is fired when the remote method raises an exception. Only the ``error`` key of the complete response  is returned.\n* ``onIdMismatch`` (*Function*) this event is fired when the JSON-RPC ID returned by the server does not match the one sent by client JSONRPC call. Thus, the complete ``response`` object is passed to the callback function, it would probably by unwise to treat it as safe.\nNote that specifying callback functions when calling ``send`` will not only override the configured callbacks, but also prevent the events from being fired, as anything listening to the events will not be able to catch them.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkphp%2Fjson-rpc-mootools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinkphp%2Fjson-rpc-mootools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkphp%2Fjson-rpc-mootools/lists"}