From: Eric S. Raymond Date: Thu, 30 Aug 2012 14:04:40 +0000 (-0400) Subject: Another tool for the dispatcher. X-Git-Tag: 1.0~72 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=50664d25730c84f2db321fd25cb502bcf37a54b3;p=irker.git Another tool for the dispatcher. --- diff --git a/irker.py b/irker.py index a1c8e69..ec82e78 100755 --- a/irker.py +++ b/irker.py @@ -184,7 +184,7 @@ class Irker: thread = threading.Thread(target=self.irc.process_forever) self.irc._thread = thread thread.start() - self.ircds = {} + self.servers = {} def logerr(self, errmsg): "Log a processing error." sys.stderr.write("irker: " + errmsg + "\n") @@ -204,6 +204,9 @@ class Irker: "Nick not accepted for this connection." if connection.context: connection.context.handle_badnick() + def drop_server(servername, port): + "Drop a server out of the server map." + del self.servers[(servername, port)] def handle(self, line): "Perform a JSON relay request." try: @@ -224,9 +227,9 @@ class Irker: self.logerr("malformed request - unexpected type: %s" % repr(request)) else: target = Target(url) - if target.server() not in self.ircds: - self.ircds[target.server()] = Dispatcher(self, target.servername, target.port) - self.ircds[target.server()].dispatch(target.channel, message) + if target.server() not in self.servers: + self.servers[target.server()] = Dispatcher(self, target.servername, target.port) + self.servers[target.server()].dispatch(target.channel, message) except ValueError: self.logerr("can't recognize JSON on input: %s" % repr(line))