当前位置: 首页>>代码示例>>Python>>正文


Python Iq.add_new_content方法代码示例

本文整理汇总了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
开发者ID:walker8088,项目名称:easyworld,代码行数:19,代码来源:filemgr.py

示例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
开发者ID:walker8088,项目名称:easyworld,代码行数:47,代码来源:filemgr.py

示例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
开发者ID:walker8088,项目名称:easyworld,代码行数:24,代码来源:filemgr.py


注:本文中的pyxmpp.iq.Iq.add_new_content方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。