From 3fc403efb63e622e10bb6db62bed86542cbfeabc Mon Sep 17 00:00:00 2001 From: Antoine Millet Date: Wed, 14 Sep 2011 17:04:27 +0200 Subject: [PATCH] Documentation enhancements. --- doc/fundamentals.rst | 24 ++++++++++++++++++++---- sjrpc/utils/handlers.py | 2 +- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/doc/fundamentals.rst b/doc/fundamentals.rst index 5804ce6..bc54713 100644 --- a/doc/fundamentals.rst +++ b/doc/fundamentals.rst @@ -15,6 +15,7 @@ Features be used without Gevent or Threading. * **Multiplexed:** sjRpc can run many "protocols" on the same connection, read more about protocols in `Multiplexing & protocols`_ section. + * **Fallback mode:** for compatibility with olders sjRpc. Multiplexing & protocols @@ -35,11 +36,26 @@ For the moment, two types of protocols are implemented: * **Tunnel:** protocol which allow to tunnel a socket through the sjRpc connection. -.. note:: - A Rpc protocol is automatically created and binded to label 0 when a - :class:`RpcConnection` class is instantiated. This can't be changed or - removed. +To register new protocols, you can use the :meth:`register_protocol` on +:class:`RpcConnection` instances, like this:: + + >>> from sjrpc.core.protocols import RpcProtocol, TunnelProtocol + >>> my_tunnel = myconn.register_protocol(1, TunnelProtocol) + + do the same on other side, then + + >>> mytunnel.send('ehlo !!') + >>> anwser = mytunnel.recv() + +You can also use shortcuts:: + + >>> my_tunnel = myconn.create_tunnel(label=12) + + or + + >>> my_tunnel = myconn.create_tunnel() # Bind to the first free label +The same shortcut is available for rpc with :meth:`create_rpc`. Default rpc, aka Rpc0 --------------------- diff --git a/sjrpc/utils/handlers.py b/sjrpc/utils/handlers.py index 50c956f..200be89 100644 --- a/sjrpc/utils/handlers.py +++ b/sjrpc/utils/handlers.py @@ -34,7 +34,7 @@ def pure(func): Function handler decorator -- the function is a pure fonction, caller will not pass :class:`RpcConnection` object as first call parameters. - .. note:: + .. deprecated:: 14 This decorator is useless since the default behavior have change. You can use :func:`pass_connection` decorator to do the opposite. -- GitLab