Skip to content
deavid edited this page Dec 24, 2010 · 17 revisions

BJSONRPC (Bi-directional JSON-RPC) is a JSON-RPC implementation aimed at speed and simplicity.

It's a good replacement to XML-RPC in environments where interactivity is critical.

It follows the JSON-RPC 1.1 specification with several additions.

Features

  • Implemented in pure python
  • TCP/IP Socket based. There is no HTTP version.
  • Connections are permanent and reused for multiple calls.
  • Low bandwith use. (aprox 60 bytes or less per call)
  • Minimal network latency. (with asyncronous calls is possible to use the full bandwith)
  • Methods can be stateful (they can remember what you called before, etc)
  • Allows (and simplifies) asynchronous calls.
  • Event-driven client and server (can be run with no threads at all)
  • Allows keyword parameters to be passed to functions.
  • Bidirectional. Client can also publish methods for server.
  • Object Oriented Programming (OOP). Objects can be created and handled remotely.
  • Client/Server Object Reference. You can create a object in the other end and tell some method to use it.
  • Server Method Reference. You can pass a server method as a parameter to a server function.

Simple examples

Server example

import bjsonrpc

class MyHandler(bjsonrpc.BaseHandler):
    def add(self,a,b): return a+b

bjsonrpc.server(handler_factory=MyHandler).serve()

Client example

import bjsonrpc

conn = bjsonrpc.connect() # defaults to 127.0.0.1:10123
print conn.call.add(2,3) # prints 5

Other pages

Clone this wiki locally