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


Python Client.deliverMethodResponse方法代码示例

本文整理汇总了Python中Client.deliverMethodResponse方法的典型用法代码示例。如果您正苦于以下问题:Python Client.deliverMethodResponse方法的具体用法?Python Client.deliverMethodResponse怎么用?Python Client.deliverMethodResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Client的用法示例。


在下文中一共展示了Client.deliverMethodResponse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: P4wnP1

# 需要导入模块: import Client [as 别名]
# 或者: from Client import deliverMethodResponse [as 别名]

#.........这里部分代码省略.........

			

	def __input_handler(self):
		while self.running:
			# processing input data


			indata = False
			bytes_rcvd = 0
			while self.tl.data_available():
				stream = self.tl.pop_input_stream()

				# deconstruct stream into channel and channel payload (network order endianess)
				ch,payload = struct.unpack("!I{0}s".format(len(stream) - 4), stream)

				if (ch == 0):
					# control channel, extract control message type
					msg_type,payload = struct.unpack("!I{0}s".format(len(payload) - 4), payload)
			
					if msg_type == P4wnP1.CTRL_MSG_FROM_CLIENT_REQ_STAGE2:
						P4wnP1.print_debug("indata: Control channel, control message STAGE2 REQUEST")
						self.client.setStage2("REQUESTED")
						# we send stage 2
						response = struct.pack("!II{0}s".format(len(self.stage2)), 0, P4wnP1.CTRL_MSG_FROM_SERVER_STAGE2_RESPONSE, self.stage2) # send back stage 2 as string on channel 0 (control channel) ...
						self.tl.write_stream(response) # ... directly to transport layer
					elif msg_type == P4wnP1.CTRL_MSG_FROM_CLIENT_RCVD_STAGE2:
						self.client.setStage2("RECEIVED")
					elif msg_type == P4wnP1.CTRL_MSG_FROM_CLIENT_STAGE2_RUNNING:
						self.client.setStage2("RUNNING")
						self.client.setConnected(True)
					elif msg_type == P4wnP1.CTRL_MSG_FROM_CLIENT_RUN_METHOD_RESPONSE:
						# handle method response
						self.client.deliverMethodResponse(payload)
					#elif msg_type == P4wnP1.CTRL_MSG_FROM_SERVER_SEND_OS_INFO:
						#self.client.setOSInfo(payload)
					#elif msg_type == P4wnP1.CTRL_MSG_FROM_SERVER_SEND_PS_VERSION:
						#self.client.setPSVersion(payload)
					#elif msg_type == P4wnP1.CTRL_MSG_FROM_CLIENT_ADD_CHANNEL:
						#self.addChannel(payload)
					elif msg_type == P4wnP1.CTRL_MSG_FROM_CLIENT_DESTROY_RESPONSE:
						self.print_reprompt("Client received terminate!")
						self.client.setConnected(False)
					elif msg_type == P4wnP1.CTRL_MSG_FROM_CLIENT_RUN_METHOD:
						#print "Run method request with following payload received: {0} ".format(repr(payload))
						pass
					elif msg_type == P4wnP1.CTRL_MSG_FROM_CLIENT_PROCESS_EXITED:
						self.onClientProcessExitted(payload)
					elif msg_type == P4wnP1.CTRL_MSG_FROM_CLIENT_CHANNEL_SHOULD_CLOSE:
						channel_id = struct.unpack("!I", payload)[0]
						self.print_reprompt("Client sent channel close request for channel ID {0}, removing channel from server...".format(channel_id))
						self.client.removeChannel(channel_id)
						# send back request to close remote channel, too
						self.sendControlMessage(P4wnP1.CTRL_MSG_FROM_SERVER_CLOSE_CHANNEL, struct.pack("!I", channel_id))
					elif msg_type == P4wnP1.CTRL_MSG_FROM_CLIENT_CHANNEL_CLOSED:
						channel_id = struct.unpack("!I", payload)[0]
						self.print_reprompt("Client confirmed close of remote channel with ID {0}!".format(channel_id))
					
					else:
						P4wnP1.print_debug("indata: Control channel, unknown control message type: {0}, payload: {1} ".format(msg_type, repr(payload)))

				else:
					# as this is not a control channel, it has to be handled by the client object
					#P4wnP1.print_debug("indata: for unknown channel channel {0}, payload: {1} ".format(ch, repr(payload)))
					#P4wnP1.print_debug("indata: for channel channel {0}, payload: {1} ".format(ch, repr(payload)))
					self.client.sendToInputChannel(ch, payload)
开发者ID:advisor25,项目名称:P4wnP1,代码行数:70,代码来源:P4wnP1.py


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