本文整理汇总了Python中twisted.words.protocols.jabber.client.IQ.toXml方法的典型用法代码示例。如果您正苦于以下问题:Python IQ.toXml方法的具体用法?Python IQ.toXml怎么用?Python IQ.toXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.words.protocols.jabber.client.IQ
的用法示例。
在下文中一共展示了IQ.toXml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_description
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import toXml [as 别名]
def on_description(self, iq):
# print(
# 'Received description from %s: %s'
# % (iq['from'], iq.toXml().encode('utf-8')))
pause = IQ(self.xmlstream, 'set')
pause['to'] = iq['from']
# enveloppe = domish.Element(
# ('http://schemas.xmlsoap.org/soap/envelope/', 'Envelope'))
enveloppe = domish.Element(
('http://schemas.xmlsoap.org/soap/envelope/', 'Envelope'), localPrefixes={'s': 'http://schemas.xmlsoap.org/soap/envelope/'})
enveloppe['s:encodingStyle'] = "http://schemas.xmlsoap.org/soap/encoding/"
header = domish.Element((None, 's:Header'))
# header = domish.Element(('http://schemas.xmlsoap.org/soap/envelope/', 'Header'))
header['mustUnderstand'] = "1"
uc = domish.Element(('urn:schemas-upnp-org:cloud-1-0', 'uc'))
uc['serviceId'] = 'urn:av-openhome-org:serviceId:Playlist'
header.addChild(uc)
enveloppe.addChild(header)
body = domish.Element((None, 's:Body'))
# body = domish.Element(('http://schemas.xmlsoap.org/soap/envelope/', 'Body'))
action = domish.Element(
('urn:av-openhome-org:service:Playlist:1', 'Read'), localPrefixes={'u': 'urn:av-openhome-org:service:Playlist:1'})
# action = domish.Element(
# ('urn:av-openhome-org:service:Playlist:1', 'Pause'))
body.addChild(action)
enveloppe.addChild(body)
pause.addChild(enveloppe)
pause.addCallback(self.paused)
print('send pause')
print(pause.toXml())
pause.send()
示例2: check_users
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import toXml [as 别名]
def check_users(self):
for user, value in self.users.items():
if value['state'] is False:
iq = IQ(self.xmlstream, 'set')
query = domish.Element(('jabber:iq:roster', 'query'))
item = domish.Element((None, 'item'))
item['name'] = user
item['jid'] = user
item.addElement('group', content='hosts')
query.addChild(item)
iq.addChild(query)
iq.addCallback(self.subscribe, user)
print('send IQ: %s' % (iq.toXml().encode('utf-8')))
iq.send()