本文整理汇总了Python中message.Message.register方法的典型用法代码示例。如果您正苦于以下问题:Python Message.register方法的具体用法?Python Message.register怎么用?Python Message.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类message.Message
的用法示例。
在下文中一共展示了Message.register方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: broadcast
# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import register [as 别名]
def broadcast(self):
network = NetworkScanner.scan_network()
repeated_devices = Message.addrs(self.msg.id)
blacklist = NetworkScanner.device_blacklist
devices = network - repeated_devices - blacklist
for addr in devices:
self.emit(self.msg, addr)
Message.register(self.msg.id, {addr})
示例2: run
# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import register [as 别名]
def run(self):
try:
self.sock.connect((self.addr, Listener.DEFAULT_PORT))
print("SENDING TO " + self.addr)
self.sock.send(pickle.dumps(self.msg))
self.sock.close()
Message.register(self.msg.id, {self.msg.sender})
except Exception as e:
self.sock.close()
if(str(e) == "52"):
NetworkScanner.device_blacklist.add(self.addr)
print(self.addr + " :: " + str(e))
print("IGNORED DEVICE: " + self.addr)
示例3: callback
# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import register [as 别名]
def callback(*args):
from event_processor import EventProcessor
handler = MessageHandler._singleton
msg = f(*args)
if(handler._valid_message(msg)):
print("RECEIVED A VALID MESSAGE")
EventProcessor.handle_message(msg.event)
handler.emit_event(msg.event, msg.sender, msg.id)
else:
# Register the sender of the message
# in case multiple people are sending us the same message
# that way we won't send to them
print("RECEIVED AN INVALID MESSAGE")
Message.register(msg.id, {msg.sender})
示例4: broadcast
# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import register [as 别名]
def broadcast(self, msg):
Message.register(msg.id, {msg.event_creator(), msg.sender})
self.plugin.broadcast(msg)