diff --git a/doc/fundamentals.rst b/doc/fundamentals.rst index 25861acd5f41fb745f372d4a5196a65b5334e031..a46c843c72436f5bf7f6e981073ac3ea0ef7a197 100644 --- a/doc/fundamentals.rst +++ b/doc/fundamentals.rst @@ -8,7 +8,7 @@ in other projects. Features -------- - * **Bidirectional:** remote function can be call by both side of the + * **Bidirectional:** remote function can be called by both side of the connection, so a client can connect to a server and export functions to it. * **Fully event based**: sjRpc takes profits of asynchronous io, allowing a server to handle thousands of client connection with a reasonable memory @@ -26,7 +26,7 @@ Server side, create the handler The handler is a simple object with a dict interface (getitem) responsible of the association between the remote-function name and the locally executed -callable. The :class:`sjrpc.utils.Handler` class allow you to define +callable. The :class:`sjrpc.utils.Handler` class help you to define an handle with a simple class extending this one:: >>> class MyHandler(RpcHandler): @@ -46,7 +46,7 @@ Server side, create the :class:`~sjrpc.core.RpcServer` instance The last thing to do on the server side is to launch the server itself:: >>> from sjrpc.server import RpcServer - >>> serv = RpcServer.from_addr('127.0.0.1', 1337n conn_kw=dict(handler=handler)) + >>> serv = RpcServer.from_addr('127.0.0.1', 1337, conn_kw=dict(handler=handler)) >>> serv.run() .. note:: @@ -59,9 +59,12 @@ Client side, just connect ! ^^^^^^^^^^^^^^^^^^^^^^^^^^^ For a basic client usage, the only thing you have to do is to create the -:class:`RpcConnection` instance to the server, nothing more simple:: +:class:`~sjrpc.core.RpcConnection` instance to the server and start the +:class:`~sjrpc.core.RpcConnection` main-loop in another thread to keep the +hands on your term:: >>> conn = RpcConnection.from_addr('127.0.0.1', 1337) + >>> threading.Thread(target=conn.run).start() >>> print conn.call('random') 42 @@ -72,6 +75,9 @@ You can also use a proxy to simplify remote calls:: >>> print proxy.random(min=42, max=1000) 587 +Proxy will also restore built-in exceptions embedded in +:class:`~sjrpc.core.RpcError`. + Multiplexing & protocols ------------------------