def connectionLost(self, reason): log.msg("Disconnected!") global message_conn if message_conn == self: message_conn = None gear_client.submit("gear_connection_lost", "")
def connectionInitialized(self): super(XmppGearsPresenceProtocol, self).connectionInitialized() self.connected = time.time() global presence_conn presence_conn = self gear_client.submit("gear_presence_connected", "")
def __onMessage(self, msg): if msg.getAttribute("type") == 'chat' and hasattr(msg, "body") and msg.body: gear_client.submit("gear_message_new", { "to": msg["to"], "from" : msg["from"], "from_bare": JID(msg["from"]).userhost(), "body": unicode(msg.body), "raw": msg.toXml().encode("utf-8")}) else: log.msg("Non-chat/body message: %s" % msg.toXml())
def _set_status(self, u, status, cb=None): if status is None: status = "available" log.msg("_set_status: %s %s" % (u, status)) gear_client.submit("gear_presence_update", { "jid" : u, "status": status } )