def __init__(self, aclient, sock, reactor, addr, sslctx=None): self._addr = addr self._reactor = reactor self._messageHandler = None adisp = self._adisp = stomp.AsyncDispatcher(aclient) if sslctx is None: try: sslctx = sock.get_context() except AttributeError: # if get_context() is missing it just means we recieved an # socket that doesn't use SSL pass else: sslctx = _SSLContextFactory(sslctx) if sslctx is None: dispatcher = Dispatcher(adisp, sock=sock, map=reactor._map) else: dispatcher = SSLDispatcher(adisp, sslctx, sock=sock, map=reactor._map) if sock is None: address_family = socket.getaddrinfo(*addr)[0][0] dispatcher.create_socket(address_family, socket.SOCK_STREAM) self._dispatcher = dispatcher
def __init__(self, sock, reactor, addr, sslctx=None): self._addr = addr self._reactor = reactor self._messageHandler = None self._impl = impl = AsyncoreClientImpl(self._handleMessage) self._chat = chat = AsyncChat(impl) if sslctx is None: try: sslctx = sock.get_context() except AttributeError: # if get_context() is missing it just means we recieved an # socket that doesn't use SSL pass else: sslctx = _SSLContextFactory(sslctx) if sslctx is None: dispatcher = Dispatcher(chat, sock=sock, map=reactor._map) else: dispatcher = SSLDispatcher(chat, sslctx, sock=sock, map=reactor._map) if sock is None: address_family = socket.getaddrinfo(*addr)[0][0] dispatcher.create_socket(address_family, socket.SOCK_STREAM) self._dispatcher = dispatcher
def __init__(self, aclient, sock, reactor): self._socket = sock self._reactor = reactor self._messageHandler = None adisp = self._adisp = stomp.AsyncDispatcher(aclient) self._dispatcher = Dispatcher(adisp, sock=sock, map=reactor._map)
def StompListener(reactor, address, acceptHandler, sslctx=None): impl = StompListenerImpl(reactor, address, acceptHandler) if sslctx is None: return Dispatcher(impl, map=reactor._map) else: sslctx = _SSLContextFactory(sslctx) return SSLDispatcher(impl, sslctx, map=reactor._map)
class _StompConnection(object): def __init__(self, aclient, sock, reactor): self._socket = sock self._reactor = reactor self._messageHandler = None adisp = self._adisp = stomp.AsyncDispatcher(aclient) self._dispatcher = Dispatcher(adisp, sock=sock, map=reactor._map) def send_raw(self, msg): self._adisp.send_raw(msg) self._reactor.wakeup() def setTimeout(self, timeout): self._dispatcher.socket.settimeout(timeout) def connect(self): pass def close(self): self._dispatcher.close()
def connect(self, address, hostname): sock = self._sock self._aclient = AsyncClient(self, hostname) adisp = self._adisp = AsyncDispatcher(self._aclient) disp = self._disp = Dispatcher(adisp, sock, self._map) sock.setblocking(True) disp.connect(address) sock.setblocking(False) self.recv() # wait for CONNECTED msg if not self._connected.isSet(): sock.close() raise socket.error()
def StompListener(reactor, acceptHandler, connected_socket): impl = StompListenerImpl(reactor, acceptHandler, connected_socket) return Dispatcher(impl, connected_socket, map=reactor._map)