Ejemplo n.º 1
0
    def listen(self, factory):
        """
        What servers do. This is Twisted-speak for "bind."

        For notes about the use of deferred here, see the deffered comment in
        the docstring for ZmqConnection.connect.
        """
        try:
            self._connectOrBind(factory)
        except Exception, err:
            msg = util.buildErrorMessage(err)
            return defer.fail(exceptions.ListenError(msg))
Ejemplo n.º 2
0
    def listen(self, factory):
        """
        What servers do. This is Twisted-speak for "bind."

        For notes about the use of deferred here, see the deffered comment in
        the docstring for ZmqConnection.connect.
        """
        try:
            self._connectOrBind(factory)
        except Exception, err:
            msg = util.buildErrorMessage(err)
            return defer.fail(exceptions.ListenError(msg))
Ejemplo n.º 3
0
    def connect(self, factory):
        """
        What clients do.

        The use of deferreds here is somewhat of an artiface, providing API
        similarity with Twisted code more than anything else. What's async in
        txZMQ is really the reactor checking the socket's file descriptor to
        see if there's data available to read or write.
        """
        try:
            self._connectOrBind(factory)
        except Exception, err:
            msg = util.buildErrorMessage(err)
            return defer.fail(exceptions.ConnectionError(msg))
Ejemplo n.º 4
0
    def connect(self, factory):
        """
        What clients do.

        The use of deferreds here is somewhat of an artiface, providing API
        similarity with Twisted code more than anything else. What's async in
        txZMQ is really the reactor checking the socket's file descriptor to
        see if there's data available to read or write.
        """
        try:
            self._connectOrBind(factory)
        except Exception, err:
            msg = util.buildErrorMessage(err)
            return defer.fail(exceptions.ConnectionError(msg))
Ejemplo n.º 5
0
    def unsubscribe(self, tag):
        """
        Unsubscribe from messages with specified tag (prefix).

        For notes about the use of deferred here, see the deffered comment in
        the docstring for ZmqConnection.connect.

        @param tag: message tag
        @type tag: C{str}
        """
        try:
            self.socket.setsockopt(constants.UNSUBSCRIBE, tag)
        except Exception, err:
            msg = util.buildErrorMessage(err)
            return defer.fail(exceptions.UnsubscribingError(msg))
Ejemplo n.º 6
0
    def publish(self, message, tag=''):
        """
        Broadcast L{message} with specified L{tag}.

        For notes about the use of deferred here, see the deffered comment in
        the docstring for ZmqConnection.connect.

        @param message: message data
        @type message: C{str}
        @param tag: message tag
        @type tag: C{str}
        """
        try:
            self.send(tag + '\0' + message)
        except Exception, err:
            msg = util.buildErrorMessage(err)
            return defer.fail(exceptions.PublishingError(msg))