autobahn.twisted.flashpolicy.
FlashPolicyProtocol
(allowedDomain, allowedPorts)[source]¶Bases: twisted.internet.protocol.Protocol
Flash Player 9 (version 9.0.124.0 and above) implements a strict new access policy for Flash applications that make Socket or XMLSocket connections to a remote host. It now requires the presence of a socket policy file on the server.
We want this to support the Flash WebSockets bridge which is needed for older browser, in particular MSIE9/8.
Parameters: | allowedPort (int) – The port to which Flash player should be allowed to connect. |
---|
REQUESTPAT
= <_sre.SRE_Pattern object>¶REQUESTMAXLEN
= 200¶REQUESTTIMEOUT
= 5¶POLICYFILE
= '<?xml version="1.0"?><cross-domain-policy><allow-access-from domain="%s" to-ports="%s" /></cross-domain-policy>'¶autobahn.twisted.flashpolicy.
FlashPolicyFactory
(allowedDomain=None, allowedPorts=None, reactor=None)[source]¶Bases: twisted.internet.protocol.Factory
Parameters: |
|
---|
buildProtocol
(addr)¶autobahn.twisted.forwarder.
DestEndpointForwardingProtocol
[source]¶Bases: twisted.internet.protocol.Protocol
connectionMade
()¶dataReceived
(data)¶connectionLost
(reason)¶autobahn.twisted.forwarder.
DestEndpointForwardingFactory
(sourceProtocol)[source]¶Bases: twisted.internet.protocol.Factory
buildProtocol
(addr)¶autobahn.twisted.forwarder.
EndpointForwardingProtocol
[source]¶Bases: twisted.internet.protocol.Protocol
connectionMade
(*args, **kwargs)¶dataReceived
(data)¶connectionLost
(reason)¶autobahn.twisted.forwarder.
EndpointForwardingService
(endpointDescriptor, destEndpointDescriptor, reactor=None)[source]¶Bases: twisted.application.service.Service
startService
(*args, **kwargs)¶stopService
()¶autobahn.twisted.longpoll.
WampLongPollResource
(factory, serializers=None, timeout=10, killAfter=30, queueLimitBytes=131072, queueLimitMessages=100, debug=False, debug_transport_id=None, reactor=None)[source]¶Bases: twisted.web.resource.Resource
A WAMP-over-Longpoll resource for use with Twisted Web Resource trees.
This class provides an implementation of the WAMP-over-Longpoll Transport for WAMP.
The Resource exposes the following paths (child resources).
Opening a new WAMP session:
<base-url>/open
Once a transport is created and the session is opened:
<base-url>/<transport-id>/send
<base-url>/<transport-id>/receive
<base-url>/<transport-id>/close
Create new HTTP WAMP Web resource.
Parameters: |
|
---|
protocol
¶alias of WampLongPollResourceSession
getChild
(name, request)[source]¶Returns send/receive/close resource for transport.
See also
twisted.web.resource.Resource
zipfile.ZipFile
autobahn.twisted.rawsocket.
WampRawSocketServerProtocol
[source]¶Bases: autobahn.twisted.rawsocket.WampRawSocketProtocol
Base class for Twisted-based WAMP-over-RawSocket server protocols.
autobahn.twisted.rawsocket.
WampRawSocketClientProtocol
[source]¶Bases: autobahn.twisted.rawsocket.WampRawSocketProtocol
Base class for Twisted-based WAMP-over-RawSocket client protocols.
autobahn.twisted.rawsocket.
WampRawSocketServerFactory
(factory, serializer, debug=False)[source]¶Bases: autobahn.twisted.rawsocket.WampRawSocketFactory
Base class for Twisted-based WAMP-over-RawSocket server factories.
Parameters: |
|
---|
protocol
¶alias of WampRawSocketServerProtocol
autobahn.twisted.rawsocket.
WampRawSocketClientFactory
(factory, serializer, debug=False)[source]¶Bases: autobahn.twisted.rawsocket.WampRawSocketFactory
Base class for Twisted-based WAMP-over-RawSocket client factories.
Parameters: |
|
---|
protocol
¶alias of WampRawSocketClientProtocol
autobahn.twisted.resource.
HTTPChannelHixie76Aware
[source]¶Bases: twisted.web.http.HTTPChannel
Hixie-76 is deadly broken. It includes 8 bytes of body, but then does not set content-length header. This hacked HTTPChannel injects the missing HTTP header upon detecting Hixie-76. We need this since otherwise Twisted Web will silently ignore the body.
To use this, set protocol = HTTPChannelHixie76Aware
on your
twisted.web.server.Site instance.
autobahn.twisted.resource.
WSGIRootResource
(wsgiResource, children)[source]¶Bases: twisted.web.resource.Resource
Root resource when you want a WSGI resource be the default serving resource for a Twisted Web site, but have subpaths served by different resources.
This is a hack needed since
twisted.web.wsgi.WSGIResource.
does not provide a putChild()
method.
Parameters: |
|
---|
autobahn.twisted.resource.
WebSocketResource
(factory)[source]¶Bases: object
A Twisted Web resource for WebSocket.
Parameters: | factory (obj) – An instance of autobahn.twisted.websocket.WebSocketServerFactory . |
---|
isLeaf
= True¶getChildWithDefault
(name, request)[source]¶This resource cannot have children, hence this will always fail.
render
(request)[source]¶Render the resource. This will takeover the transport underlying
the request, create a autobahn.twisted.websocket.WebSocketServerProtocol
and let that do any subsequent communication.
autobahn.twisted.wamp.
ApplicationSession
(config=None)[source]¶Bases: autobahn.twisted.wamp.FutureMixin
, autobahn.wamp.protocol.ApplicationSession
WAMP application session for Twisted-based applications.
Constructor.
autobahn.twisted.wamp.
ApplicationSessionFactory
(config=None)[source]¶Bases: autobahn.twisted.wamp.FutureMixin
, autobahn.wamp.protocol.ApplicationSessionFactory
WAMP application session factory for Twisted-based applications.
Parameters: | config (instance of autobahn.wamp.types.ComponentConfig ) – The default component configuration. |
---|
session
¶The application session class this application session factory will use. Defaults to autobahn.twisted.wamp.ApplicationSession
.
alias of ApplicationSession
autobahn.twisted.wamp.
ApplicationRunner
(url, realm, extra=None, debug=False, debug_wamp=False, debug_app=False)[source]¶This class is a convenience tool mainly for development and quick hosting of WAMP application components.
It can host a WAMP application component in a WAMP-over-WebSocket client connecting to a WAMP router.
Parameters: |
|
---|
run
(make, start_reactor=True)[source]¶Run the application component.
Parameters: | make (callable) – A factory that produces instances of autobahn.asyncio.wamp.ApplicationSession
when called with an instance of autobahn.wamp.types.ComponentConfig . |
---|
autobahn.twisted.wamp.
Application
(prefix=None)[source]¶A WAMP application. The application object provides a simple way of creating, debugging and running WAMP application components.
Parameters: | prefix (unicode) – The application URI prefix to use for procedures and topics,
e.g. "com.example.myapp" . |
---|
run
(url=u'ws://localhost:8080/ws', realm=u'realm1', debug=False, debug_wamp=False, debug_app=False, start_reactor=True)[source]¶Run the application.
Parameters: |
---|
register
(uri=None)[source]¶Decorator exposing a function as a remote callable procedure.
The first argument of the decorator should be the URI of the procedure to register under.
Example: |
---|
@app.register('com.myapp.add2')
def add2(a, b):
return a + b
Above function can then be called remotely over WAMP using the URI com.myapp.add2 the function was registered under.
If no URI is given, the URI is constructed from the application URI prefix and the Python function name.
Example: |
---|
app = Application('com.myapp')
# implicit URI will be 'com.myapp.add2'
@app.register()
def add2(a, b):
return a + b
If the function yields (is a co-routine), the @inlineCallbacks decorator will be applied automatically to it. In that case, if you wish to return something, you should use returnValue:
Example: |
---|
from twisted.internet.defer import returnValue
@app.register('com.myapp.add2')
def add2(a, b):
res = yield stuff(a, b)
returnValue(res)
Parameters: | uri (unicode) – The URI of the procedure to register under. |
---|
subscribe
(uri=None)[source]¶Decorator attaching a function as an event handler.
The first argument of the decorator should be the URI of the topic to subscribe to. If no URI is given, the URI is constructed from the application URI prefix and the Python function name.
If the function yield, it will be assumed that it’s an asynchronous process and inlineCallbacks will be applied to it.
Example: |
---|
@app.subscribe('com.myapp.topic1')
def onevent1(x, y):
print("got event on topic1", x, y)
Parameters: | uri (unicode) – The URI of the topic to subscribe to. |
---|
signal
(name)[source]¶Decorator attaching a function as handler for application signals.
Signals are local events triggered internally and exposed to the developer to be able to react to the application lifecycle.
If the function yield, it will be assumed that it’s an asynchronous coroutine and inlineCallbacks will be applied to it.
Current signals :
- onjoined: Triggered after the application session has joined the
realm on the router and registered/subscribed all procedures and event handlers that were setup via decorators.
onleave: Triggered when the application session leaves the realm.
@app.signal('onjoined')
def _():
# do after the app has join a realm
Parameters: | name (unicode) – The name of the signal to watch. |
---|
autobahn.twisted.websocket.
WebSocketAdapterProtocol
[source]¶Bases: twisted.internet.protocol.Protocol
Adapter class for Twisted WebSocket client and server protocols.
autobahn.twisted.websocket.
WebSocketServerProtocol
[source]¶Bases: autobahn.twisted.websocket.WebSocketAdapterProtocol
, autobahn.websocket.protocol.WebSocketServerProtocol
Base class for Twisted-based WebSocket server protocols.
autobahn.twisted.websocket.
WebSocketClientProtocol
[source]¶Bases: autobahn.twisted.websocket.WebSocketAdapterProtocol
, autobahn.websocket.protocol.WebSocketClientProtocol
Base class for Twisted-based WebSocket client protocols.
autobahn.twisted.websocket.
WebSocketAdapterFactory
[source]¶Adapter class for Twisted-based WebSocket client and server factories.
autobahn.twisted.websocket.
WebSocketServerFactory
(*args, **kwargs)[source]¶Bases: autobahn.twisted.websocket.WebSocketAdapterFactory
, autobahn.websocket.protocol.WebSocketServerFactory
, twisted.internet.protocol.ServerFactory
Base class for Twisted-based WebSocket server factories.
In addition to all arguments to the constructor of
autobahn.websocket.protocol.WebSocketServerFactory
,
you can supply a reactor keyword argument to specify the
Twisted reactor to be used.
autobahn.twisted.websocket.
WebSocketClientFactory
(*args, **kwargs)[source]¶Bases: autobahn.twisted.websocket.WebSocketAdapterFactory
, autobahn.websocket.protocol.WebSocketClientFactory
, twisted.internet.protocol.ClientFactory
Base class for Twisted-based WebSocket client factories.
In addition to all arguments to the constructor of
autobahn.websocket.protocol.WebSocketClientFactory
,
you can supply a reactor keyword argument to specify the
Twisted reactor to be used.
autobahn.twisted.websocket.
WrappingWebSocketAdapter
[source]¶An adapter for stream-based transport over WebSocket.
This follows websockify and should be compatible with that.
It uses WebSocket subprotocol negotiation and supports the following WebSocket subprotocols:
binary
(or a compatible subprotocol)base64
Octets are either transmitted as the payload of WebSocket binary
messages when using the binary
subprotocol (or an alternative
binary compatible subprotocol), or encoded with Base64 and then
transmitted as the payload of WebSocket text messages when using
the base64
subprotocol.
autobahn.twisted.websocket.
WrappingWebSocketServerProtocol
[source]¶Bases: autobahn.twisted.websocket.WrappingWebSocketAdapter
, autobahn.twisted.websocket.WebSocketServerProtocol
Server protocol for stream-based transport over WebSocket.
autobahn.twisted.websocket.
WrappingWebSocketClientProtocol
[source]¶Bases: autobahn.twisted.websocket.WrappingWebSocketAdapter
, autobahn.twisted.websocket.WebSocketClientProtocol
Client protocol for stream-based transport over WebSocket.
autobahn.twisted.websocket.
WrappingWebSocketServerFactory
(factory, url, reactor=None, enableCompression=True, autoFragmentSize=0, subprotocol=None, debug=False)[source]¶Bases: autobahn.twisted.websocket.WebSocketServerFactory
Wrapping server factory for stream-based transport over WebSocket.
Parameters: |
|
---|
autobahn.twisted.websocket.
WrappingWebSocketClientFactory
(factory, url, reactor=None, enableCompression=True, autoFragmentSize=0, subprotocol=None, debug=False)[source]¶Bases: autobahn.twisted.websocket.WebSocketClientFactory
Wrapping client factory for stream-based transport over WebSocket.
Parameters: |
|
---|
autobahn.twisted.websocket.
connectWS
(factory, contextFactory=None, timeout=30, bindAddress=None)[source]¶Establish WebSocket connection to a server. The connection parameters like target host, port, resource and others are provided via the factory.
Parameters: |
|
---|---|
Returns: | The connector. |
Return type: | An object which implements twisted.interface.IConnector. |
autobahn.twisted.websocket.
listenWS
(factory, contextFactory=None, backlog=50, interface='')[source]¶Listen for incoming WebSocket connections from clients. The connection parameters like listening port and others are provided via the factory.
Parameters: |
|
---|---|
Returns: | The listening port. |
Return type: | An object that implements twisted.interface.IListeningPort. |
autobahn.twisted.websocket.
WampWebSocketServerProtocol
[source]¶Bases: autobahn.wamp.websocket.WampWebSocketServerProtocol
, autobahn.twisted.websocket.WebSocketServerProtocol
Base class for Twisted-based WAMP-over-WebSocket server protocols.
autobahn.twisted.websocket.
WampWebSocketServerFactory
(factory, *args, **kwargs)[source]¶Bases: autobahn.wamp.websocket.WampWebSocketServerFactory
, autobahn.twisted.websocket.WebSocketServerFactory
Base class for Twisted-based WAMP-over-WebSocket server factories.
protocol
¶alias of WampWebSocketServerProtocol
autobahn.twisted.websocket.
WampWebSocketClientProtocol
[source]¶Bases: autobahn.wamp.websocket.WampWebSocketClientProtocol
, autobahn.twisted.websocket.WebSocketClientProtocol
Base class for Twisted-based WAMP-over-WebSocket client protocols.
autobahn.twisted.websocket.
WampWebSocketClientFactory
(factory, *args, **kwargs)[source]¶Bases: autobahn.wamp.websocket.WampWebSocketClientFactory
, autobahn.twisted.websocket.WebSocketClientFactory
Base class for Twisted-based WAMP-over-WebSocket client factories.
protocol
¶alias of WampWebSocketClientProtocol