本文整理汇总了Python中Message.Message.getFromJson方法的典型用法代码示例。如果您正苦于以下问题:Python Message.getFromJson方法的具体用法?Python Message.getFromJson怎么用?Python Message.getFromJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message.Message
的用法示例。
在下文中一共展示了Message.getFromJson方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UdpServerHandler
# 需要导入模块: from Message import Message [as 别名]
# 或者: from Message.Message import getFromJson [as 别名]
class UdpServerHandler(SocketServer.BaseRequestHandler):
"""This is a class handles mocap state information received from UDP."""
# Setup logging
logger = logging.getLogger('UdpServerHandler')
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(levelname)s %(asctime)s %(name)s Line: %(lineno)d | %(message)s')
handler = logging.StreamHandler()
handler.setFormatter(formatter)
logger.addHandler(handler)
# Class constants
# -----------------------------------------------------------------------
# Class Functions
# -----------------------------------------------------------------------
# None
# -----------------------------------------------------------------------
# Instance Functions
# -----------------------------------------------------------------------
def __init__(self, request, client_address, server):
self.rcvd_msg = None
SocketServer.BaseRequestHandler.__init__(self, request, client_address, server)
def setup(self):
SocketServer.BaseRequestHandler.setup(self)
def handle(self):
UdpServerHandler.logger.debug('Handling a UDP packet.')
json_message = self.request[0].strip()
self.rcvd_msg = Message()
self.rcvd_msg.getFromJson(json_message)
self.rcvd_msg.rx_time = datetime.now()
def finish(self):
SocketServer.BaseRequestHandler.finish(self)