本文整理汇总了Python中Client.setStage2方法的典型用法代码示例。如果您正苦于以下问题:Python Client.setStage2方法的具体用法?Python Client.setStage2怎么用?Python Client.setStage2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client
的用法示例。
在下文中一共展示了Client.setStage2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: P4wnP1
# 需要导入模块: import Client [as 别名]
# 或者: from Client import setStage2 [as 别名]
#.........这里部分代码省略.........
# process pending output from client channels
###############################################
pendingOut = self.client.getPendingChannelOutput()
if len(pendingOut) > 0:
# push data to transport layer
for stream in pendingOut:
self.tl.write_stream(stream)
#time.sleep(5)
#time.sleep(0.1)
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: