This commit is contained in:
Tobias Oberstein
2014-01-28 19:24:21 +01:00
parent 1c5ee2ac19
commit b31179895e
8 changed files with 400 additions and 12 deletions

View File

@@ -61,6 +61,13 @@ class Handler:
@implementer(ISession)
class WampBaseSession:
"""
WAMP application session base class.
This class implements:
* :class:`autobahn.wamp.interfaces.ISession`
"""
def __init__(self):
self._ecls_to_uri_pat = {}
@@ -165,8 +172,22 @@ class WampBaseSession:
@implementer(ICallee)
@implementer(ITransportHandler)
class WampAppSession(WampBaseSession):
"""
WAMP application session.
This class implements:
* :class:`autobahn.wamp.interfaces.IPublisher`
* :class:`autobahn.wamp.interfaces.ISubscriber`
* :class:`autobahn.wamp.interfaces.ICaller`
* :class:`autobahn.wamp.interfaces.ICallee`
* :class:`autobahn.wamp.interfaces.ITransportHandler`
"""
def __init__(self, broker = None, dealer = None):
"""
Constructor.
"""
WampBaseSession.__init__(self)
self._transport = None
@@ -560,6 +581,18 @@ class WampAppSession(WampBaseSession):
self._peer_session_id = None
def onSessionOpen(self, details):
"""
Implements :func:`autobahn.wamp.interfaces.ISession.onSessionOpen`
"""
def onSessionClose(self, details):
"""
Implements :func:`autobahn.wamp.interfaces.ISession.onSessionClose`
"""
def closeSession(self, reason = None, message = None):
"""
Implements :func:`autobahn.wamp.interfaces.ISession.closeSession`
@@ -723,8 +756,22 @@ class WampAppSession(WampBaseSession):
class WampAppFactory:
"""
WAMP application session factory.
"""
session = WampAppSession
"""
WAMP application session class to be used in this factory.
"""
def __call__(self):
"""
Creates a new WAMP application session.
:returns: -- An instance of the WAMP application session class as
given by `self.session`.
"""
session = self.session()
session.factory = self
return session
@@ -824,24 +871,49 @@ class WampRouterAppSession:
class WampRouterSession(WampAppSession):
def onSessionOpen(self, details):
print "WampRouterSession.onSessionOpen", details.me, details.peer
def onSessionClose(self, details):
print "WampRouterSession.onSessionClose", details.reason, details.message
"""
WAMP router session.
"""
class WampRouterFactory:
"""
WAMP router session factory.
"""
session = WampRouterSession
"""
WAMP router session class to be used in this factory.
"""
def __init__(self):
"""
Constructor.
"""
self._broker = Broker()
self._dealer = Dealer()
self._app_sessions = []
def add(self, app_session):
self._app_sessions.append(WampRouterAppSession(app_session, self._broker, self._dealer))
def add(self, session):
"""
Adds a WAMP application session to run directly in this router.
:param: session: A WAMP application session.
:type session: A instance of a class that derives of :class:`autobahn.wamp.protocol.WampAppSession`
"""
self._app_sessions.append(WampRouterAppSession(session, self._broker, self._dealer))
def __call__(self):
return WampRouterSession(self._broker, self._dealer)
"""
Creates a new WAMP router session.
:returns: -- An instance of the WAMP router session class as
given by `self.session`.
"""
session = self.session(self._broker, self._dealer)
session.factory = session
return session

View File

@@ -52,9 +52,9 @@ copyright = u'2011-2014 Tavendo GmbH'
# built documents.
#
# The short X.Y version.
version = '0.7'
version = '0.8'
# The full version, including alpha/beta/rc tags.
release = '0.7.3'
release = '0.8.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View File

@@ -6,7 +6,8 @@ Autobahn|Python Reference
:maxdepth: 3
websockettoc
wamptoc
wamp1toc
wamp2
* :ref:`genindex`

31
doc/wamp1base.rst Normal file
View File

@@ -0,0 +1,31 @@
Base
====
The classes :class:`autobahn.wamp1.protocol.WampProtocol` and
:class:`autobahn.wamp1.protocol.WampFactory` are additional base classes ("mixins")
for the WAMP v1 client and server classes. They contain functionality
common to both client and server roles.
Factory
-------
.. autoclass:: autobahn.wamp1.protocol.WampFactory
Protocol
--------
.. autoclass:: autobahn.wamp1.protocol.WampProtocol
:members: URI_WAMP_BASE,
URI_WAMP_PROCEDURE,
URI_WAMP_TOPIC,
URI_WAMP_ERROR,
URI_WAMP_ERROR_GENERIC,
URI_WAMP_ERROR_INTERNAL,
shrink,
resolve
.. autoclass:: autobahn.wamp1.protocol.WampCraProtocol
:members: authSignature

32
doc/wamp1client.rst Normal file
View File

@@ -0,0 +1,32 @@
Client
======
The classes :class:`autobahn.wamp1.protocol.WampClientProtocol` and
:class:`autobahn.wamp1.protocol.WampClientFactory` are the base classes
you derive from to implement WAMP v1 clients.
Factory
-------
.. autoclass:: autobahn.wamp1.protocol.WampClientFactory
:members: startFactory,
stopFactory
Protocol
--------
.. autoclass:: autobahn.wamp1.protocol.WampClientProtocol
:members: onSessionOpen,
prefix,
call,
publish,
subscribe,
unsubscribe
.. autoclass:: autobahn.wamp1.protocol.WampCraClientProtocol
:members: authenticate

45
doc/wamp1server.rst Normal file
View File

@@ -0,0 +1,45 @@
Server
======
The classes :class:`autobahn.wamp1.protocol.WampServerProtocol` and
:class:`autobahn.wamp1.protocol.WampServerFactory` are the base classes
you derive from to implement WAMP v1 servers.
Factory
-------
.. autoclass:: autobahn.wamp1.protocol.WampServerFactory
:members: dispatch,
sessionIdsToProtos,
protosToSessionIds,
startFactory,
stopFactory
Protocol
--------
.. autoclass:: autobahn.wamp1.protocol.WampServerProtocol
:members: onSessionOpen,
dispatch,
registerForRpc,
registerMethodForRpc,
registerProcedureForRpc,
registerHandlerMethodForRpc,
registerHandlerProcedureForRpc,
registerForPubSub,
registerHandlerForPubSub,
registerHandlerForSub,
registerHandlerForPub
.. autoclass:: autobahn.wamp1.protocol.WampCraServerProtocol
:members: clientAuthTimeout,
clientAuthAllowAnonymous,
getAuthSecret,
getAuthPermissions,
onAuthenticated,
onAuthTimeout,
registerForPubSubFromPermissions

9
doc/wamp1toc.rst Normal file
View File

@@ -0,0 +1,9 @@
WAMP v1
=======
.. toctree::
:maxdepth: 3
wamp1base
wamp1client
wamp1server

198
doc/wamp2.rst Normal file
View File

@@ -0,0 +1,198 @@
WAMP v2
=======
Interfaces
----------
.. autointerface:: autobahn.wamp.interfaces.IObjectSerializer
:members:
.. autointerface:: autobahn.wamp.interfaces.IMessage
:members:
.. autointerface:: autobahn.wamp.interfaces.ISerializer
:members:
.. autointerface:: autobahn.wamp.interfaces.ITransport
:members:
.. autointerface:: autobahn.wamp.interfaces.ITransportHandler
:members:
.. autointerface:: autobahn.wamp.interfaces.ISession
:members:
.. autointerface:: autobahn.wamp.interfaces.ICaller
:members:
.. autointerface:: autobahn.wamp.interfaces.ICallee
:members:
.. autointerface:: autobahn.wamp.interfaces.IPublisher
:members:
.. autointerface:: autobahn.wamp.interfaces.ISubscriber
:members:
.. autointerface:: autobahn.wamp.interfaces.IRouter
:members:
.. autointerface:: autobahn.wamp.interfaces.IBroker
:members:
.. autointerface:: autobahn.wamp.interfaces.IDealer
:members:
Errors
------
.. autoclass:: autobahn.wamp.exception.Error
:show-inheritance:
:members: __init__
.. autoclass:: autobahn.wamp.exception.SessionNotReady
:show-inheritance:
:members: __init__
.. autoclass:: autobahn.wamp.exception.ProtocolError
:show-inheritance:
:members: __init__
.. autoclass:: autobahn.wamp.exception.TransportLost
:show-inheritance:
:members: __init__
.. autoclass:: autobahn.wamp.exception.ApplicationError
:show-inheritance:
:members: __init__
.. autoclass:: autobahn.wamp.exception.NotAuthorized
:show-inheritance:
:members: __init__
.. autoclass:: autobahn.wamp.exception.InvalidTopic
:show-inheritance:
:members: __init__
.. autoclass:: autobahn.wamp.exception.CallError
:show-inheritance:
:members: __init__
.. autoclass:: autobahn.wamp.exception.CanceledError
:show-inheritance:
:members: __init__
Router
------
.. autoclass:: autobahn.wamp.broker.Broker
:show-inheritance:
:members: __init__,
addSession,
removeSession,
processMessage
.. autoclass:: autobahn.wamp.dealer.Dealer
:show-inheritance:
:members: __init__,
addSession,
removeSession,
processMessage
Protocol
--------
.. autoclass:: autobahn.wamp.protocol.WampBaseSession
:show-inheritance:
:members: define
.. autoclass:: autobahn.wamp.protocol.WampAppSession
:show-inheritance:
:members: __init__,
onOpen,
onMessage,
onClose,
onSessionOpen,
onSessionClose,
closeSession,
publish,
subscribe,
unsubscribe,
call,
register,
unregister
.. autoclass:: autobahn.wamp.protocol.WampAppFactory
:show-inheritance:
:members: __call__
.. autoclass:: autobahn.wamp.protocol.WampRouterAppSession
:show-inheritance:
:members: __init__,
send
.. autoclass:: autobahn.wamp.protocol.WampRouterSession
:show-inheritance:
.. autoclass:: autobahn.wamp.protocol.WampRouterFactory
:show-inheritance:
:members: __init__,
add,
__call__
Types
-----
.. autoclass:: autobahn.wamp.types.SessionDetails
:show-inheritance:
:members: __init__
.. autoclass:: autobahn.wamp.types.CloseDetails
:show-inheritance:
:members: __init__
.. autoclass:: autobahn.wamp.types.SubscribeOptions
:show-inheritance:
:members: __init__
.. autoclass:: autobahn.wamp.types.EventDetails
:show-inheritance:
:members: __init__
.. autoclass:: autobahn.wamp.types.PublishOptions
:show-inheritance:
:members: __init__
.. autoclass:: autobahn.wamp.types.RegisterOptions
:show-inheritance:
:members: __init__
.. autoclass:: autobahn.wamp.types.CallDetails
:show-inheritance:
:members: __init__
.. autoclass:: autobahn.wamp.types.CallOptions
:show-inheritance:
:members: __init__
.. autoclass:: autobahn.wamp.types.CallResult
:show-inheritance:
:members: __init__