webstompy¶
webstompy.transporter¶
All transporter objects (WebSocket et al.) to transport the STOMP messages.
webstompy.connection¶
StompConnection: a STOMP connection
-
class
webstompy.connection.
StompConnection
(connector=None, transporter=<class 'webstompy.transporter.transporter.WebSocketTransporter'>)[source]¶ Bases:
object
StompConnection: a STOMP connection
Parameters: - connector – The connector to communicate over, to be used in transporter
- transporter (webstompy.transporter.transporter.BaseTransporter) – The transporter to handle the actual communication with the connector (in most cases a webstompy.transporter.transporter.WebSocketTransporter)
-
add_listener
(listener)[source]¶ Add a listener to be invoked in case of events.
Parameters: listener (webstompy.StompListener) – Listener to be derived from webstompy.StompListener.
-
alive
¶ Detect whether connection is still alive.
Returns: is_alive – Whether connection is still alive. Return type: bool
-
connect
(login=None, passcode=None, timeout=None)[source]¶ Connect to the STOMP server
Parameters: - login (str) – The user id used to authenticate against a secured STOMP server (None to login without user id).
- passcode (str) – The password used to authenticate against a secured STOMP server (None to login without password).
- timeout (int) – Timeout to wait for the confirmation of the connection from the server (None means: wait forever).
Returns: frame_connected – The CONNECTED frame upon success.
Return type: webstompy.StompFrame
-
send
(destination, message='', content_type='text/plain', content_length=None)[source]¶ Send a message to the STOMP server
Parameters: - destination str – The destination to send this message to (required).
- message str – The message body to send.
- content_type str – Content type of the message body.
- content_length (int) – Content length of the message body (byte count).
webstompy.exception¶
webstompy exceptions
-
exception
webstompy.exception.
ConnectFailedException
(message)[source]¶ Bases:
webstompy.exception.WebstompyException
Raised by StompConnection.connect when no connection could be established.
-
exception
webstompy.exception.
ConnectionClosedException
(message)[source]¶ Bases:
webstompy.exception.WebstompyException
Raised when no connection was closed.
-
exception
webstompy.exception.
NoDestinationException
[source]¶ Bases:
webstompy.exception.WebstompyException
Raised when no STOMP destination was specified where it was required.
-
exception
webstompy.exception.
NoIdException
[source]¶ Bases:
webstompy.exception.WebstompyException
Raised when no STOMP id was specified where it was required.
webstompy.frame¶
StompFrame: a STOMP data frame
-
class
webstompy.frame.
StompFrame
(command=None, header=None, message=None, payload=None)[source]¶ Bases:
object
StompFrame: a STOMP data frame
A StompFrame can either be constructed from command, header, and message. Or from the complete byte payload of e.g. a server response.
Parameters: - command (str) – The command of this STOMP frame.
- header (list) – The headers of this STOMP frame as list of key, value tuples (string).
- message (str) – The message of this STOMP frame.
- payload (bytes) – The complete byte payload of this STOMP frame.
-
command
¶ The command of this STOMP frame.
-
header
¶ The headers of this STOMP frame as list of key, value tuples
-
json
¶ The message of this STOMP frame as JSON data
-
message
¶ The message of this STOMP frame.
-
payload
¶ The complete byte payload of this STOMP frame.
webstompy.listener¶
StompListener: base class for a listener which will be invoked upon message arrival
webstompy.receiver¶
StompReceiver: a STOMP receiver to be run in a thread
-
class
webstompy.receiver.
StompReceiver
(transporter, queue_frames, queue_listener)[source]¶ Bases:
threading.Thread
StompReceiver: a STOMP receiver to be run in a thread
Parameters: - connector – The connector to communicate over, to be used in transporter
- queue_frames (queue.Queue) – The queue to put the frames in this StompReceiver receives
- queue_listener (queue.Queue) – The queue for webstompy.StompListener to invoke upon events
- transporter (webstompy.transporter.transporter.BaseTransporter) – The transporter instance to handle the actual communication with the connector (in most cases a webstompy.transporter.transporter.WebSocketTransporter)
-
run
()[source]¶ Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.