Hmm. I'm not sure if SleekXMPP is doing the wrong thing, or I'm using it the wrong way. No matter what I do, I cannot seem to actually receive the Iq costume request sent by Paragon Chat. I even registered a stanza callback to show me *all* Iq requests, and it goes so far as to show me the Iq traffic that sets up the SSL handshake. It shows me the Iq traffic for rosters. And yet it does not ever show me the Iq costume request.
Completely separately, I seem to be not understanding substanza semantics quite right. I tried to do this:
class pcAppearanceStanza(ElementBase):
namespace = 'pc:costume'
name = 'appearance'
plugin_attrib = 'appearance'
interfaces = set(('bodytype','skincolor','scale','bone','head','shoulder','chest',
'waist','hip','leg','head3d','brow3d','cheek3d','chin3d','cranium3d',
'jaw3d','nose3d'))
class pcPartStanza(ElementBase):
namespace = 'pc:costume'
name = 'part'
plugin_attrib = 'part'
interfaces = set(('n','geom','tex1','tex2','fx','color1','color2','color3','color4'))
class pcCostumeStanza(ElementBase):
namespace = 'pc:costume'
name = 'costume'
plugin_attrib = 'costume'
interfaces = set(('hash', 'appearance', 'parts'))
subitem = (pcAppearanceStanza, pcPartStanza)
def getParts(self):
parts = {}
for pt in self.xml.findall('{%s}part' % pcPartStanza.namespace):
part = pcPartStanza(pt)
parts[part['n']] = part['value']
return parts
def setParts(self,parts):
for part in parts:
self.addPart(part)
def delParts(self):
parts = self.xml.findall('{%s}part' % pcPartStanza.namespace)
for part in parts:
self.xml.remove(part)
return
def addPart(self, part_dict):
part_obj = Part(None, self)
for element in ['n','tex1','tex2','fx','color1','color2','color3','color4']:
if element in part_dict:
part_obj[element] = part_dict[element]
return
def delPart(self, n):
parts = self.xml.findall('{%s}part' % pcPartStanza.namespace)
for partXML in parts:
part = pcPartStanza(partXML)
if part['n'] == n:
self.xml.remove(partXML)
return
registerStanzaPlugin(Iq,pcCostumeStanza)
That should register <costume /> as a substanza of Iq, and <appearance /> and <part /> as substanzas of <costume /> but that doesn't quite seem to work right either, because this doesn't work:
cStanza['costume']['appearance']['bodytype'] = pcCostumeDict['BodyType']
That throws a unicode error, implying I'm indirecting incorrectly off of that Stanza object. I'm beginning to wonder if doing this from literal raw TCP traffic wouldn't have been faster. It gets off the ground quickly, but past the 50% mark I've been fighting the framework almost as often as using it. Something simple like "show me every Iq stanza that arrives on the wire" should be bulletproof. It ain't.
JSON would have, in fact, been quicker. :p