本文整理匯總了Python中pyxmpp.iq.Iq.add_new_content方法的典型用法代碼示例。如果您正苦於以下問題:Python Iq.add_new_content方法的具體用法?Python Iq.add_new_content怎麽用?Python Iq.add_new_content使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyxmpp.iq.Iq
的用法示例。
在下文中一共展示了Iq.add_new_content方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: send_close_request
# 需要導入模塊: from pyxmpp.iq import Iq [as 別名]
# 或者: from pyxmpp.iq.Iq import add_new_content [as 別名]
def send_close_request(self, session) :
'''
<iq type='set'
from='[email protected]/orchard'
to='[email protected]/balcony'
id='inband_2'>
<close xmlns='http://jabber.org/protocol/ibb' sid='mySID'/>
</iq>
'''
stream = self.client.get_stream()
new_id = stream.generate_id()
iq = Iq(None, session.jid, session.to_jid, "set", new_id)
node = iq.add_new_content(IBB_NS, 'close')
node.setProp('sid', session.sid)
stream.set_response_handlers(iq, self.received_close_success, self.received_close_error)
stream.send(iq)
self.active_sessions[new_id] = session
示例2: send_si_request
# 需要導入模塊: from pyxmpp.iq import Iq [as 別名]
# 或者: from pyxmpp.iq.Iq import add_new_content [as 別名]
def send_si_request(self, session) :
'''
<iq type='set' id='offer1' to='[email protected]/resource'>
<si xmlns='http://jabber.org/protocol/si' id='a0' mime-type='text/plain' profile='http://jabber.org/protocol/si/profile/file-transfer'>
<file xmlns='http://jabber.org/protocol/si/profile/file-transfer' name='test.txt' size='1022' hash='552da749930852c69ae5d2141d3766b1' date='1969-07-21T02:56:15Z'>
<desc>This is a test. If this were a real file...</desc>
</file>
<feature xmlns='http://jabber.org/protocol/feature-neg'>
<x xmlns='jabber:x:data' type='form'>
<field var='stream-method' type='list-single'>
<option><value>>>http://jabber.org/protocol/bytestreams</value></option>
<option><value>>>http://jabber.org/protocol/ibb</value></option>
</field>
</x>
</feature>
</si>
</iq>
'''
stream = self.client.get_stream()
#new_id = stream.generate_id()
iq = Iq(None, session.jid, session.to_jid, "set", session.sid)
si_node = iq.add_new_content(SI_NS, 'si')
si_node.setProp("id", session.sid)
si_node.setProp("mime-type", 'application/octet-stream')
si_node.setProp("profile", FILE_TRANSFER_NS)
file_node = si_node.newChild(None,"file",None)
file_node.setProp("xmlns", FILE_TRANSFER_NS)
file_node.setProp("name", to_utf8(session.file_name))
file_node.setProp("size", to_utf8(session.file_size))
feature_node = si_node.newChild(None, "feature", None)
feature_node.setProp("xmlns", FEATURE_NS)
form = Form()
form.add_field( name = 'stream-method', field_type = 'list-single',
#options = [Option('http://jabber.org/protocol/bytestreams', None), Option('http://jabber.org/protocol/ibb', None)])
options = [Option('http://jabber.org/protocol/ibb', None)])
form.as_xml(feature_node)
stream.set_response_handlers(iq, self.received_si_success, self.received_si_error)
stream.send(iq)
self.sessions[session.sid] = session
示例3: send_data_request
# 需要導入模塊: from pyxmpp.iq import Iq [as 別名]
# 或者: from pyxmpp.iq.Iq import add_new_content [as 別名]
def send_data_request(self, session, data) :
'''
<iq from='[email protected]/orchard' to='[email protected]/balcony' type='set' id='ibb1'>
<data xmlns='http://jabber.org/protocol/ibb' sid='mySID' seq='0'>
qANQR1DBwU4DX7jmYZnncmUQB/9KuKBddzQH+tZ1ZywKK0yHKnq57kWq+RFtQdCJ
WpdWpR0uQsuJe7+vh3NWn59/gTc5MDlX8dS9p0ovStmNcyLhxVgmqS8ZKhsblVeu
IpQ0JgavABqibJolc3BKrVtVV1igKiX/N7Pi8RtY1K18toaMDhdEfhBRzO/XB0+P
AQhYlRjNacGcslkhXqNjK5Va4tuOAPy2n1Q8UUrHbUd0g+xJ9Bm0G0LZXyvCWyKH
kuNEHFQiLuCY6Iv0myq6iX6tjuHehZlFSh80b5BVV9tNLwNR5Eqz1klxMhoghJOA
</data>
</iq>
'''
stream = self.client.get_stream()
new_id = stream.generate_id()
iq = Iq(None, session.jid, session.to_jid, "set", new_id)
node = iq.add_new_content(IBB_NS, 'data')
node.setProp('sid', session.sid)
node.setProp('seq', str(session.seq))
node.setContent(base64.b64encode(data))
stream.set_response_handlers(iq, self.received_data_success, self.received_data_error)
stream.send(iq)
self.active_sessions[new_id] = session