From a8a5d5129eb59f539fcc1e66217b07c04cec7ed8 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Fri, 30 Jul 2004 18:18:37 +0000 Subject: [PATCH] Another attempt to allow multiple servers in twistedDrivers. --- src/twistedDrivers.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/twistedDrivers.py b/src/twistedDrivers.py index 865decebc..eb5d93795 100644 --- a/src/twistedDrivers.py +++ b/src/twistedDrivers.py @@ -96,7 +96,8 @@ class SupyReconnectingFactory(ReconnectingClientFactory): self.irc = irc self.networkGroup = conf.supybot.networks.get(self.irc.network) self.servers = () - reactor.connectTCP('', 0, self) + (server, port) = self._getNextServer() + reactor.connectTCP(server, port, self) def _getServers(self): # We do this, rather than itertools.cycle the servers in __init__, @@ -113,8 +114,15 @@ class SupyReconnectingFactory(ReconnectingClientFactory): self.currentServer = '%s:%s' % server return server + def clientConnectionFailed(self, connector, r): + (connector.host, connector.port) = self._getNextServer() + ReconnectingClientFactory.clientConnectionFailed(self, connector, r) + + def clientConnectionLost(self, connector, r): + (connector.host, connector.port) = self._getNextServer() + ReconnectingClientFactory.clientConnectionLost(self, connector, r) + def buildProtocol(self, addr): - addr = self._getNextServer() protocol = ReconnectingClientFactory.buildProtocol(self, addr) protocol.irc = self.irc return protocol