本文整理汇总了Python中Message.serialize方法的典型用法代码示例。如果您正苦于以下问题:Python Message.serialize方法的具体用法?Python Message.serialize怎么用?Python Message.serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message.serialize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resp_username_illegal
# 需要导入模块: import Message [as 别名]
# 或者: from Message import serialize [as 别名]
def resp_username_illegal(self, msg):
resp = Message()
resp.response = 'login'
resp.error = 'Invalid username!'
resp.username = msg.username
resp.serialize()
self.connection.sendall(resp)
示例2: resp_username_taken
# 需要导入模块: import Message [as 别名]
# 或者: from Message import serialize [as 别名]
def resp_username_taken(self, msg):
resp = Message()
resp.response = 'login'
resp.error = 'Name already taken!'
resp.username = msg.username
resp.serialize()
self.connection.sendall(resp)
示例3: resp_login_success
# 需要导入模块: import Message [as 别名]
# 或者: from Message import serialize [as 别名]
def resp_login_success(self, msg):
self.username = msg.username
#update the servers list of clients
lock.acquire()
self.server.add_client(self, self.username)
history = self.server.get_messages()
lock.release()
#send response to client
resp = Message()
resp.response = 'login'
resp.username = msg.username
resp.messages = history
resp.serialize()
self.connection.sendall(resp)
示例4: send_to_client
# 需要导入模块: import Message [as 别名]
# 或者: from Message import serialize [as 别名]
def send_to_client(self, msg):
m = Message()
m.response = 'message'
m.message = msg
m.serialize()
self.connection.sendall(m)