def on_core_connection_made(self): logger.warn("core_connection_made: %s" % self.key) mode = self.core.proc_match(self.query["regex"].encode("utf8")) proc = self.query["proc"].encode("utf8") self.core.send_proc(mode, proc) self.core.flush() self.xmpp.active[self.key] = self
def redis_pooling(self): data0 = yield self.redis.hgetall("leela.xmpp") for (key, conn) in list(self.active.iteritems()): if (key not in data0): logger.warn("reaping connection: %s" % (key,)) conn.shutdown() for (key, data1) in data0.iteritems(): data = parser.parse_json(data1) if (key not in self.active): logger.debug("spawning connection: %s: %s" % (key, data["sender"])) conn = Connection(key, xmppim.JID(data["sender"]), data["request"]["select"], self) self.core.connect(conn.factory())
def relay(self, packet, sync=False): if (len(self.queue) < MAXQUEUE): self.queue.append(packet) else: logger.warn("discarding packet, queue full!!!") packet = "".join(self.queue[:25]) flags = sync and 0 or socket.MSG_DONTWAIT try: self.fd.sendto(packet, flags, self.socket) del (self.queue[:25]) self.packages += len(packet.split(";")) except socket.error: pass
def relay(self, packet, sync=False): if (len(self.queue) < MAXQUEUE): self.queue.append(packet) else: logger.warn("discarding packet, queue full!!!") packet = "".join(self.queue[:25]) flags = sync and 0 or socket.MSG_DONTWAIT try: self.fd.sendto(packet, flags, self.socket) del(self.queue[:25]) self.packages += len(packet.split(";")) except socket.error: pass
def datagramReceived(self, string, peer): try: if (string == "ping\n" or string == "ping"): self.handle_ping(peer) else: self.handle_event(string) except ValueError: if (logger.level <= logger.DEBUG): logger.exception() except Exception, e: logger.warn("error receiving packet [peer: %s, %s]" % (repr(peer), e)) if (logger.level <= logger.DEBUG): logger.exception()
def startService(self): service.Service.startService(self) logger.warn("starting cassandra service") self.dbus.attach("storage", self) self.storage.startService() self.loop.start(1)
def startProtocol(self): logger.warn("starProtocol")
def stopProtocol(self): logger.warn("stopProtocol")
def connectionRefused(self): logger.warn("connectionRefused") reactor.callLater(1, self.connect)
def stopService(self): logger.warn("stoppping cassandra service") self.loop.stop() self.dbus.detach("storage") self.storage.stopService() service.Service.stopService(self)
def connectionFailed(self, reason): logger.warn("connectionLost: %s" % reason.getErrorMessage()) reactor.callLater(1, self.connect)
def unsubscribeReceived(self, presence): logger.warn("unsubscription received: %s/%s" % (presence.sender, presence.recipient)) self.unsubscribed(presence.sender) self.unsubscribe(presence.sender)
def shutdown(self): logger.warn("disconnecting: %s" % self.key) self.core.send_close()