本文整理汇总了Python中twisted.words.protocols.jabber.client.IQ.send方法的典型用法代码示例。如果您正苦于以下问题:Python IQ.send方法的具体用法?Python IQ.send怎么用?Python IQ.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.words.protocols.jabber.client.IQ
的用法示例。
在下文中一共展示了IQ.send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getStats
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import send [as 别名]
def getStats(self, jid = "icq.netlab.cz"):
iq = IQ(self.xmlstream, "get")
iq['to'] = jid
iq.addElement(("http://jabber.org/protocol/stats", "query"))
iq.addCallback(self._statsReceived)
iq.send()
示例2: on_description
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import send [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()
示例3: _send_socks5_reply
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import send [as 别名]
def _send_socks5_reply(self, id, stream_used):
result = IQ(self.stream, 'result')
result['id'] = id
result['from'] = self.target
result['to'] = self.initiator
query = result.addElement((ns.BYTESTREAMS, 'query'))
streamhost_used = query.addElement((None, 'streamhost-used'))
streamhost_used['jid'] = stream_used
result.send()
示例4: invalid_user
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import send [as 别名]
def invalid_user(self, xs):
iq = IQ(self.xmlstream, "set")
iq.addElement(("jabber:iq:register", "query"))
iq.query.addElement("username", content = self.jid.user)
iq.query.addElement("password", content = self.password)
iq.addCallback(self._registerResultEvent)
iq.send()
示例5: authenticated
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import send [as 别名]
def authenticated(self, xs):
presence = domish.Element((None, 'presence'))
xs.send(presence)
iq = IQ(self.xmlstream, "set")
iq.addElement(("jabber:iq:register", "query"))
iq.query.addElement("remove")
iq.addCallback(self._result)
iq.send()
示例6: _statsReceived
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import send [as 别名]
def _statsReceived(self, el):
iq = IQ(self.xmlstream, "get")
iq['to'] = el['from']
q = iq.addElement(("http://jabber.org/protocol/stats", "query"))
query = el.firstChildElement()
for child in query.children:
s = q.addElement('stat')
s['name'] = child['name']
iq.addCallback(self._statsDataReceived)
iq.send()
示例7: registerAccount
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import send [as 别名]
def registerAccount(self, username=None, password=None):
if username:
self.jid.user = username
if password:
self.password = password
iq = IQ(self.xmlstream, "set")
iq.addElement(("jabber:iq:register", "query"))
iq.query.addElement("username", content=self.jid.user)
iq.query.addElement("password", content=self.password)
iq.addCallback(self._registerResultEvent)
iq.send()
示例8: check_users
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import send [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.cloud_subscribe, user)
# print('send IQ: %s' % (iq.toXml().encode('utf-8')))
iq.send()
示例9: authenticated
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import send [as 别名]
def authenticated(self, xs):
self.log.debug('Cloud Authenticated')
presence = domish.Element((None, 'presence'))
xs.send(presence)
xs.addObserver('/presence', self.on_presence)
xs.addObserver('/iq', self.on_iq)
xs.addObserver('/message', self.on_event)
disco = IQ(xs, 'get')
disco.addElement(('http://jabber.org/protocol/disco#items', 'query'))
disco.addCallback(self.cloud_discovered)
disco.send()
# self.reactor.callLater(120, xs.sendFooter)
self.reactor.callLater(5, self.check_users)
示例10: _result2
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import send [as 别名]
def _result2(self, iq):
if iq['type'] != 'result':
self.failed()
query = iq.firstChildElement()
if query.name != "query":
self.failed()
iq = IQ(self.xmlstream, "get")
iq['to'] = transport
iq.addElement(("jabber:iq:register", "query"))
iq.addCallback(self._result3)
iq.send()
示例11: __call__
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import send [as 别名]
def __call__(self, *args, **kwargs):
d = defer.Deferred()
self.ctx, = self.contexts
self.get_out_object(self.ctx, args, kwargs)
self.get_out_string(self.ctx)
self.ctx.in_string = []
action = IQ(self.url[0], 'set')
for item in self.ctx.out_string:
action.addRawXml(item)
if action.callbacks:
action.addCallback(self.on_response, d)
else:
print('wtf?')
action.send(to=self.url[1])
return d
示例12: _result
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import send [as 别名]
def _result(self, iq):
#<iq from='icq.localhost' to='[email protected]/test' id='H_24' type='result'><query xmlns='jabber:iq:register'><instructions>Enter your Jabber ID and password:</instructions><username/><password/><x xmlns='jabber:x:data' type='form'><title>Registration</title><instructions>Enter your Jabber ID and password:</instructions><field type='hidden' var='FORM_TYPE'><value>jabber:iq:register</value></field><field type='text-single' var='username' label='Network username'><required/></field><field type='text-private' var='password' label='Password'><required/></field><field type='list-single' var='language' label='Language'><value>en</value><option label='Cesky'><value>cs</value></option><option label='English'><value>en</value></option></field></x></query></iq>
# TODO: more tests
if iq['type'] != 'result':
self.failed()
query = iq.firstChildElement()
if query.name != "query":
self.failed()
iq = IQ(self.xmlstream, "set")
iq['to'] = transport
iq.addElement(("jabber:iq:register", "query"))
iq.query.addElement("username", content = client_jid1.userhost())
iq.query.addElement("password", content = secret1)
iq.addCallback(self._result2)
iq.send()
示例13: on_presence
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import send [as 别名]
def on_presence(self, resp):
print('got presence: %s' % resp.toXml().encode('utf-8'))
print('from :%s' % resp['from'])
user, host, res = parse(resp['from'])
jid = '@'.join((user, host))
if resp.hasAttribute('type'):
if resp['type'] == 'subscribed':
if jid in self.users:
self.users[jid].update({'state': True})
if 'services' in self.users[jid]:
self.users[jid]['services'].append(res)
else:
self.users[jid].update({'services': [res]})
presence = domish.Element((None, 'presence'))
presence['type'] = 'subscribe'
presence['to'] = resp['from']
self.xmlstream.send(presence)
else:
presence = domish.Element((None, 'presence'))
presence['type'] = 'denying'
presence['to'] = resp['from']
self.xmlstream.send(presence)
elif resp['type'] == 'unsubscribed':
if jid in self.users:
print('subscription failed: %s' % resp['from'])
return
for child in resp.elements():
if child.name == 'ConfigIdCloud':
print('Found UPnP Cloud device : %s type is: %s' % (
jid,
res))
# if jid == self._jid:
# return
info = IQ(self.xmlstream, 'get')
info['to'] = resp ['from']
query = domish.Element(
('urn:schemas-upnp-org:cloud-1-0', 'query'))
query['type'] = 'description'
query['name'] = ':'.join(res.split(':')[-2:])
info.addChild(query)
info.addCallback(self.on_description)
info.send()
示例14: unsubscribe_cloud
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import send [as 别名]
def unsubscribe_cloud(self, name):
def unsubscribed(name, d, res):
if res['type'] == 'result':
# print('unsubscribed: %s' % name)
del self.subscriptions_cloud[name]
print('ok')
d.callback(None)
else:
d.errback(Exception(res.toXml()))
d = defer.Deferred()
iq = IQ(self.xmlstream, 'set')
ps = domish.Element(('http://jabber.org/protocol/pubsub', 'pubsub'))
unsubscribe = domish.Element((None, 'unsubscribe'))
unsubscribe['node'] = name
unsubscribe['jid'] = self.jid.full()
ps.addChild(unsubscribe)
iq.addChild(ps)
iq.addCallback(unsubscribed, name, d)
iq.send(to='pubsub.' + self.jid.host)
return d
示例15: authenticated
# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import send [as 别名]
def authenticated(self, xs):
print "Authenticated."
# bind = IQ(xs, 'set')
# # res = domish.Element((None, 'resource'), content=self.resource)
# res = domish.Element(('urn:ietf:params:xml:ns:xmpp-bind', 'bind'))
# res.addElement('resource', content=self.resource)
# bind.addChild(res)
# # bind['from'] = self._jid
# # bind['to'] = self.jid.host
# xs.send(bind)
presence = domish.Element((None, 'presence'))
xs.send(presence)
xs.addObserver('/presence', self.on_presence)
xs.addObserver('/iq', self.on_iq)
disco = IQ(xs, 'get')
# disco['to'] = '[email protected]/urn:schemas-upnp-org:device:MediaRenderer:1:uuid:e70e9d0e-d9eb-4748-b163-636a323e7950'
# search = domish.Element(('http://jabber.org/protocol/disco#items', 'query'))
disco.addElement(('http://jabber.org/protocol/disco#items', 'query'))
disco.addCallback(self.discovered)
disco.send()
self.reactor.callLater(120, xs.sendFooter)
self.reactor.callLater(5, self.check_users)