mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 14:59:34 +01:00
Fixed reconnects.
This commit is contained in:
parent
ee74036505
commit
dc8b430754
@ -27,7 +27,7 @@ class SupyIrcProtocol(LineReceiver):
|
|||||||
delimiter = '\n'
|
delimiter = '\n'
|
||||||
MAX_LENGTH = 1024
|
MAX_LENGTH = 1024
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
reactor.callLater(1, self.checkIrcForMsgs)
|
self.mostRecentCall = reactor.callLater(1, self.checkIrcForMsgs)
|
||||||
|
|
||||||
def lineReceived(self, line):
|
def lineReceived(self, line):
|
||||||
start = time.time()
|
start = time.time()
|
||||||
@ -42,22 +42,28 @@ class SupyIrcProtocol(LineReceiver):
|
|||||||
def checkIrcForMsgs(self):
|
def checkIrcForMsgs(self):
|
||||||
if self.connected:
|
if self.connected:
|
||||||
msg = self.factory.irc.takeMsg()
|
msg = self.factory.irc.takeMsg()
|
||||||
while msg:
|
if msg:
|
||||||
self.transport.write(str(msg))
|
self.transport.write(str(msg))
|
||||||
msg = self.factory.irc.takeMsg()
|
|
||||||
self.mostRecentCall = reactor.callLater(1, self.checkIrcForMsgs)
|
self.mostRecentCall = reactor.callLater(1, self.checkIrcForMsgs)
|
||||||
|
|
||||||
def connectionLost(self):
|
def connectionLost(self):
|
||||||
self.mostRecentCall.cancel()
|
self.mostRecentCall.cancel()
|
||||||
|
|
||||||
|
def connectionMade(self):
|
||||||
|
self.factory.irc.driver = self
|
||||||
|
self.factory.irc.reset()
|
||||||
|
#self.mostRecentCall = reactor.callLater(1, self.checkIrcForMsgs)
|
||||||
|
|
||||||
def die(self):
|
def die(self):
|
||||||
self.transport.loseConnection()
|
self.transport.loseConnection()
|
||||||
|
|
||||||
|
|
||||||
class SupyReconnectingFactory(ReconnectingClientFactory):
|
class SupyReconnectingFactory(ReconnectingClientFactory):
|
||||||
maxDelay = 600
|
maxDelay = 600
|
||||||
protocol = SupyIrcProtocol
|
protocol = SupyIrcProtocol
|
||||||
def __init__(self, (server, port), irc):
|
def __init__(self, (server, port), irc):
|
||||||
self.irc = irc
|
self.irc = irc
|
||||||
|
self.server = (server, port)
|
||||||
reactor.connectTCP(server, port, self)
|
reactor.connectTCP(server, port, self)
|
||||||
|
|
||||||
|
|
||||||
@ -83,6 +89,8 @@ if conf.telnetEnable and __name__ != '__main__':
|
|||||||
reactor.listenTCP(conf.telnetPort, MyShellFactory())
|
reactor.listenTCP(conf.telnetPort, MyShellFactory())
|
||||||
|
|
||||||
|
|
||||||
|
Driver = SupyReconnectingFactory
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ignore(poller)
|
ignore(poller)
|
||||||
except NameError:
|
except NameError:
|
||||||
|
Loading…
Reference in New Issue
Block a user