""" import logging from twisted.internet import defer, task from twisted.python import failure from stompest.error import StompConnectionError, StompFrameError from stompest.protocol import StompSession, StompSpec from stompest.util import checkattr from stompest.twisted import util, listener from stompest.twisted.protocol import StompProtocolCreator LOG_CATEGORY = __name__ connected = checkattr('_protocol') class Stomp(object): """An asynchronous STOMP client for the Twisted framework. :param config: A :class:`~.StompConfig` object. :param listenersFactory: The listeners which this (parameterless) function produces will be added to the connection each time :meth:`~.twisted.client.Stomp.connect` is called. The default behavior (:obj:`None`) is to use :func:`~.twisted.listener.defaultListeners` in the module :mod:`twisted.listener`. :param endpointFactory: This function produces a Twisted endpoint which will be used to establish the wire-level connection. It accepts two arguments **broker** (as it is produced by iteration over an :obj:`~.protocol.failover.StompFailoverTransport`) and **timeout** (connect timeout in seconds, :obj:`None` meaning that we will wait indefinitely). The default behavior (:obj:`None`) is to use :func:`~.twisted.util.endpointFactory` in the module :mod:`twisted.util`. .. note :: All API methods which may request a **RECEIPT** frame from the broker -- which is indicated by the **receipt** parameter -- will wait for the **RECEIPT** response until this client's :obj:`~.twisted.listener.ReceiptListener`'s **timeout** (given that one was added to this client, which by default is not the case). Here, "wait" is to be understood in the asynchronous sense that the method's :class:`twisted.internet.defer.Deferred` result will only call back then. If **receipt** is :obj:`None`, no such header is sent, and the callback will be triggered earlier. .. seealso :: :class:`~.StompConfig` for how to set configuration options, :class:`~.StompSession` for session state, :mod:`.protocol.commands` for all API options which are documented here. Details on endpoints can be found in the `Twisted endpoint howto <http://twistedmatrix.com/documents/current/core/howto/endpoints.html>`_. """ protocolCreatorFactory = StompProtocolCreator
--- """ import collections import contextlib import logging import time from stompest.error import StompConnectionError, StompProtocolError from stompest.protocol import StompFailoverTransport, StompFrame, StompSession from stompest.util import checkattr from stompest.sync.transport import StompFrameTransport LOG_CATEGORY = __name__ connected = checkattr('_transport') class Stomp(object): """A synchronous STOMP client. This is the successor of the simple STOMP client in stompest 1.x, but the API is not backward compatible. :param config: A :class:`~.StompConfig` object .. seealso :: :class:`~.StompConfig` for how to set session configuration options, :class:`~.StompSession` for session state, :mod:`.protocol.commands` for all API options which are documented here. """ _failoverFactory = StompFailoverTransport _transportFactory = StompFrameTransport def __init__(self, config): self.log = logging.getLogger(LOG_CATEGORY) self._config = config
API --- """ import logging from twisted.internet import defer, task from stompest.error import StompConnectionError, StompFrameError from stompest.protocol import StompSession, StompSpec from stompest.util import checkattr from . import util, listener from .protocol import StompProtocolCreator LOG_CATEGORY = __name__ connected = checkattr('_protocol') class Stomp(object): """An asynchronous STOMP client for the Twisted framework. :param config: A :class:`~.StompConfig` object. :param listenersFactory: The listeners which this (parameterless) function produces will be added to the connection each time :meth:`~.async.client.Stomp.connect` is called. The default behavior (:obj:`None`) is to use :func:`~.async.listener.defaultListeners` in the module :mod:`async.listener`. :param endpointFactory: This function produces a Twisted endpoint which will be used to establish the wire-level connection. It accepts two arguments **broker** (as it is produced by iteration over an :obj:`~.protocol.failover.StompFailoverTransport`) and **timeout** (connect timeout in seconds, :obj:`None` meaning that we will wait indefinitely). The default behavior (:obj:`None`) is to use :func:`~.async.util.endpointFactory` in the module :mod:`async.util`. .. note :: All API methods which may request a **RECEIPT** frame from the broker -- which is indicated by the **receipt** parameter -- will wait for the **RECEIPT** response until this client's :obj:`~.async.listener.ReceiptListener`'s **timeout** (given that one was added to this client, which by default is not the case). Here, "wait" is to be understood in the asynchronous sense that the method's :class:`twisted.internet.defer.Deferred` result will only call back then. If **receipt** is :obj:`None`, no such header is sent, and the callback will be triggered earlier. .. seealso :: :class:`~.StompConfig` for how to set configuration options, :class:`~.StompSession` for session state, :mod:`.protocol.commands` for all API options which are documented here. Details on endpoints can be found in the `Twisted endpoint howto <http://twistedmatrix.com/documents/current/core/howto/endpoints.html>`_. """ protocolCreatorFactory = StompProtocolCreator def __init__(self, config, listenersFactory=None, endpointFactory=None):
""" import collections import contextlib import logging import time from stompest.error import StompConnectionError, StompProtocolError from stompest.protocol import StompFailoverTransport, StompSession from stompest.util import checkattr from .transport import StompFrameTransport from stompest.protocol import commands LOG_CATEGORY = __name__ connected = checkattr('_transport') class Stomp(object): """A synchronous STOMP client. This is the successor of the simple STOMP client in stompest 1.x, but the API is not backward compatible. :param config: A :class:`~.StompConfig` object .. seealso :: :class:`~.StompConfig` for how to set session configuration options, :class:`~.StompSession` for session state, :mod:`.protocol.commands` for all API options which are documented here. """ _failoverFactory = StompFailoverTransport _transportFactory = StompFrameTransport def __init__(self, config): self.log = logging.getLogger(LOG_CATEGORY) self._config = config self._session = StompSession(self._config.version, self._config.check)