本文整理汇总了Python中message.Message.msgtype方法的典型用法代码示例。如果您正苦于以下问题:Python Message.msgtype方法的具体用法?Python Message.msgtype怎么用?Python Message.msgtype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类message.Message
的用法示例。
在下文中一共展示了Message.msgtype方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testClient
# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import msgtype [as 别名]
def testClient(num):
s = gevent.socket.create_connection(("localhost", 12345))
m = Message()
mg = MessageGenerator()
# Request server info
m.msgtype = 0
s.send(m.rawData())
q = s.recv(100)
mg.addData(q)
g = mg.generate()
msg2 = g.next()
print msg2.msgtype
print msg2.value
# get plugin list
m.msgtype = 1
s.send(m.rawData())
q = s.recv(100)
mg.addData(q)
msg2 = g.next()
print msg2.msgtype
print msg2.value
# get device list
m.msgtype = 100
s.send(m.rawData())
q = s.recv(100)
mg.addData(q)
msg2 = g.next()
print msg2.msgtype
print msg2.value
# claim device
m.msgtype = 1002
m.value = [0]
s.send(m.rawData())
iterations = random.randrange(1000, 10000)
for i in range(0, iterations):
q = s.recv(100)
mg.addData(q)
msg2 = g.next()
if i % 100 == 0:
print "%d : %d" % (num, i)
# print msg2.msgtype
# print msg2.value
# m.msgtype = 1001
# s.send(m.rawData())
# time.sleep(1)
s.close()
示例2: socket
# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import msgtype [as 别名]
from socket import socket
from message import Message, MessageGenerator
import time
s = socket()
s.connect(("localhost", 12345))
m = Message()
mg = MessageGenerator()
# Request server info
m.msgtype = 0
s.send(m.rawData())
q = s.recv(100)
mg.addData(q)
g = mg.generate()
msg2 = g.next()
print msg2.msgtype
print msg2.value
# get plugin list
m.msgtype = 1
s.send(m.rawData())
q = s.recv(100)
mg.addData(q)
msg2 = g.next()
print msg2.msgtype
print msg2.value
# get device list
m.msgtype = 100
s.send(m.rawData())