This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.python import log | |
from txamqp.content import Content | |
BOT_PROTOCOL_LIST = ['jabber'] | |
NON_PERSISTENT = 1 | |
class queueWriter: | |
_chan = None | |
def __init__(self, conn, exchange, basename): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.python import log | |
BOT_PROTOCOL_LIST = ['jabber'] | |
class queueReader: | |
def __init__(self, conn, exchange, basename): | |
self._conn = conn | |
self._basename = basename | |
self._exchange = exchange |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def associateConnection(self, connection): | |
log.msg("associating") | |
self._conn = connection | |
self.openChannel().addCallback(self.write, "Test").addErrback(log.err) | |
def openChannel(self): | |
def _openChann(channel): | |
log.msg("Opening channel") | |
t = channel.channel_open().addCallback( lambda _: channel.queue_declare(queue=self._basename + "_out", durable=True, exclusive=False, auto_delete=False)).addErrback(log.err) | |
t.addCallback(lambda _: channel.queue_bind(queue=self._basename + "_out", exchange=self._exchange, routing_key= "txamqp_" + self._basename)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prepareExchanges(self, conn): | |
def _openChann(channel): | |
channel.channel_open().addCallback( lambda _, c: c.exchange_declare(exchange=self._exchange, type="direct", durable=True, auto_delete=False), channel ) | |
log.msg("preparing") | |
self._chan = conn.channel(1) | |
return self._chan.addCallback(_openChann) | |