Skip to content

Instantly share code, notes, and snippets.

@legastero
Created May 22, 2010 13:08
Show Gist options
  • Select an option

  • Save legastero/410067 to your computer and use it in GitHub Desktop.

Select an option

Save legastero/410067 to your computer and use it in GitHub Desktop.
Changes needed to make XMPP-TDG example 14-7 work with SleekXMPP version 1.0
def handleIncomingXMPPMessage(self, event) :
message = self.addRecipientToMessage(event["body"], event["to"].jid)
user = self.backend.getUserFromJID(event["from"].jid)
self.backend.addMessageFromUser(message, user)
def handleIncomingXMPPPresence(self, event) :
if event["to"].jid == self.componentDomain :
user = self.backend.getUserFromJID(event["from"].jid)
self.backend.addMessageFromUser(event["status"], user)
...
def handleXMPPPresenceSubscription(self, subscription) :
if subscription["type"] == "subscribe" :
userJID = subscription["from"].jid
user = self.backend.getUserFromJID(userJID)
contactJID = subscription["to"]
self.xmpp.sendPresenceSubscription(
pfrom=contactJID, pto=userJID, ptype="subscribed", pnick=user)
self.sendPresenceOfContactToUser(contactJID=contactJID, userJID=userJID)
if contactJID == self.componentDomain :
self.sendAllContactSubscriptionRequestsToUser(userJID)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment