/usr/lib/python2.7/dist-packages/stomp/connect.py is in python-stomp 4.1.19-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | """Main entry point for clients to create a STOMP connection.
Provides connection classes for `1.0 <http://stomp.github.io/stomp-specification-1.0.html>`_,
`1.1 <http://stomp.github.io/stomp-specification-1.1.html>`_, and
`1.2 <http://stomp.github.io/stomp-specification-1.2.html>`_ versions of the STOMP protocol.
"""
from stomp.listener import *
from stomp.protocol import *
from stomp.transport import *
class BaseConnection(Publisher):
"""
Base class for all connection classes.
"""
def __init__(self, transport):
"""
:param Transport transport:
"""
self.transport = transport
def set_listener(self, name, lstnr):
"""
:param str name:
:param ConnectionListener lstnr:
"""
self.transport.set_listener(name, lstnr)
def remove_listener(self, name):
"""
:param str name:
"""
self.transport.remove_listener(name)
def get_listener(self, name):
"""
:param str name:
:rtype: ConnectionListener
"""
return self.transport.get_listener(name)
def start(self):
self.transport.start()
def stop(self):
self.transport.stop()
def is_connected(self):
"""
:rtype: bool
"""
return self.transport.is_connected()
def set_receipt(self, receipt_id, value):
self.transport.set_receipt(receipt_id, value)
def set_ssl(self, *args, **kwargs):
self.transport.set_ssl(*args, **kwargs)
def get_ssl(self, *args, **kwargs):
self.transport.get_ssl(*args, **kwargs)
class StompConnection10(BaseConnection, Protocol10):
"""
Represents a 1.0 connection (comprising transport plus 1.0 protocol class).
See :py:class:`stomp.transport.Transport` for details on the initialisation parameters.
"""
def __init__(self,
host_and_ports=None,
prefer_localhost=True,
try_loopback_connect=True,
reconnect_sleep_initial=0.1,
reconnect_sleep_increase=0.5,
reconnect_sleep_jitter=0.1,
reconnect_sleep_max=60.0,
reconnect_attempts_max=3,
use_ssl=False,
ssl_key_file=None,
ssl_cert_file=None,
ssl_ca_certs=None,
ssl_cert_validator=None,
wait_on_receipt=False,
ssl_version=DEFAULT_SSL_VERSION,
timeout=None,
keepalive=None,
auto_decode=True,
auto_content_length=True):
transport = Transport(host_and_ports, prefer_localhost, try_loopback_connect,
reconnect_sleep_initial, reconnect_sleep_increase, reconnect_sleep_jitter,
reconnect_sleep_max, reconnect_attempts_max, use_ssl, ssl_key_file, ssl_cert_file,
ssl_ca_certs, ssl_cert_validator, wait_on_receipt, ssl_version, timeout,
keepalive, None, auto_decode)
BaseConnection.__init__(self, transport)
Protocol10.__init__(self, transport, auto_content_length)
def disconnect(self, receipt=None, headers=None, **keyword_headers):
"""
Call the protocol disconnection, and then stop the transport itself.
:param str receipt: the receipt to use with the disconnect
:param dict headers: a map of any additional headers to send with the disconnection
:param keyword_headers: any additional headers to send with the disconnection
"""
Protocol10.disconnect(self, receipt, headers, **keyword_headers)
self.transport.stop()
class StompConnection11(BaseConnection, Protocol11):
"""
Represents a 1.1 connection (comprising transport plus 1.1 protocol class)
See :py:class:`stomp.transport.Transport` for details on the initialisation parameters.
"""
def __init__(self,
host_and_ports=None,
prefer_localhost=True,
try_loopback_connect=True,
reconnect_sleep_initial=0.1,
reconnect_sleep_increase=0.5,
reconnect_sleep_jitter=0.1,
reconnect_sleep_max=60.0,
reconnect_attempts_max=3,
use_ssl=False,
ssl_key_file=None,
ssl_cert_file=None,
ssl_ca_certs=None,
ssl_cert_validator=None,
wait_on_receipt=False,
ssl_version=DEFAULT_SSL_VERSION,
timeout=None,
heartbeats=(0, 0),
keepalive=None,
vhost=None,
auto_decode=True,
auto_content_length=True):
transport = Transport(host_and_ports, prefer_localhost, try_loopback_connect,
reconnect_sleep_initial, reconnect_sleep_increase, reconnect_sleep_jitter,
reconnect_sleep_max, reconnect_attempts_max, use_ssl, ssl_key_file, ssl_cert_file,
ssl_ca_certs, ssl_cert_validator, wait_on_receipt, ssl_version, timeout,
keepalive, vhost, auto_decode)
BaseConnection.__init__(self, transport)
Protocol11.__init__(self, transport, heartbeats, auto_content_length)
def disconnect(self, receipt=None, headers=None, **keyword_headers):
"""
Call the protocol disconnection, and then stop the transport itself.
:param str receipt: the receipt to use with the disconnect
:param dict headers: a map of any additional headers to send with the disconnection
:param keyword_headers: any additional headers to send with the disconnection
"""
Protocol11.disconnect(self, receipt, headers, **keyword_headers)
self.transport.stop()
class StompConnection12(BaseConnection, Protocol12):
"""
Represents a 1.2 connection (comprising transport plus 1.2 protocol class).
See :py:class:`stomp.transport.Transport` for details on the initialisation parameters.
"""
def __init__(self,
host_and_ports=None,
prefer_localhost=True,
try_loopback_connect=True,
reconnect_sleep_initial=0.1,
reconnect_sleep_increase=0.5,
reconnect_sleep_jitter=0.1,
reconnect_sleep_max=60.0,
reconnect_attempts_max=3,
use_ssl=False,
ssl_key_file=None,
ssl_cert_file=None,
ssl_ca_certs=None,
ssl_cert_validator=None,
wait_on_receipt=False,
ssl_version=DEFAULT_SSL_VERSION,
timeout=None,
heartbeats=(0, 0),
keepalive=None,
vhost=None,
auto_decode=True,
auto_content_length=True):
transport = Transport(host_and_ports, prefer_localhost, try_loopback_connect,
reconnect_sleep_initial, reconnect_sleep_increase, reconnect_sleep_jitter,
reconnect_sleep_max, reconnect_attempts_max, use_ssl, ssl_key_file, ssl_cert_file,
ssl_ca_certs, ssl_cert_validator, wait_on_receipt, ssl_version, timeout,
keepalive, vhost, auto_decode)
BaseConnection.__init__(self, transport)
Protocol12.__init__(self, transport, heartbeats, auto_content_length)
def disconnect(self, receipt=None, headers=None, **keyword_headers):
"""
Call the protocol disconnection, and then stop the transport itself.
:param str receipt: the receipt to use with the disconnect
:param dict headers: a map of any additional headers to send with the disconnection
:param keyword_headers: any additional headers to send with the disconnection
"""
Protocol12.disconnect(self, receipt, headers, **keyword_headers)
self.transport.stop()
|