本文整理匯總了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)