crossbar.bridge.mqtt.wamp¶
Attributes¶
Classes¶
This is a factory which produces protocols. |
|
This is the base class for streaming connection-oriented protocols. |
|
Functions¶
|
Convert a MQTT topic as used in MQTT Subscribe (and hence ptoentially containing |
|
Convert a MQTT topic as used in MQTT Publish to a WAMP URI. |
|
Convert a WAMP URI as used in WAMP Publish to a MQTT topic. |
Module Contents¶
- class WampMQTTServerFactory(router_session_factory, config, reactor)[source]¶
Bases:
twisted.internet.protocol.FactoryThis is a factory which produces protocols.
By default, buildProtocol will create a protocol of the class given in self.protocol.
- _get_payload_format(topic)[source]¶
Map a WAMP topic URI to MQTT payload format. :param topic: WAMP URI. :type topic: str
- Returns:
Payload format metadata.
- Return type:
- _transform_mqtt_native(serializer, payload)[source]¶
Transform MQTT binary payload from a MQTT Publish to keyword dict suitable for the constructor of a WAMP Publish message, that is
autobahn.wamp.message.Publish.
- buildProtocol(addr)[source]¶
Create an instance of a subclass of Protocol.
The returned instance will handle input on an incoming server connection, and an attribute “factory” pointing to the creating factory.
Alternatively, L{None} may be returned to immediately close the new connection.
Override this method to alter how Protocol instances get created.
@param addr: an object implementing L{IAddress}
- class WampMQTTServerProtocol(reactor)[source]¶
Bases:
twisted.internet.protocol.ProtocolThis is the base class for streaming connection-oriented protocols.
If you are going to write a new connection-oriented protocol for Twisted, start here. Any protocol implementation, either client or server, should be a subclass of this class.
The API is quite simple. Implement L{dataReceived} to handle both event-based and synchronous input; output can be sent through the ‘transport’ attribute, which is to be an instance that implements L{twisted.internet.interfaces.ITransport}. Override C{connectionLost} to be notified when the connection ends.
Some subclasses exist already to help you write common types of protocols: see the L{twisted.protocols.basic} module for a few of them.
- _publish(event, acknowledge=None)[source]¶
Given a MQTT event, create a WAMP Publish message and forward that on the forwarding WAMP session.
- connectionLost(reason)[source]¶
Called when the connection is shut down.
Clear any circular references here, and any external references to this Protocol. The connection has been closed.
@type reason: L{twisted.python.failure.Failure}
- connectionMade(ignore_handshake=False)[source]¶
Called when a connection is made.
This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.
- dataReceived(data)[source]¶
Called whenever data is received.
Use this method to translate to a higher-level message. Usually, some callback will be made upon the receipt of each complete protocol message.
- @param data: a string of indeterminate length. Please keep in mind
that you will probably need to buffer some data, as partial (or multiple) protocol messages may be received! I recommend that unit tests for protocols call through to this method with differing chunk sizes, down to one byte at a time.