本文整理匯總了Python中Message.get_json方法的典型用法代碼示例。如果您正苦於以下問題:Python Message.get_json方法的具體用法?Python Message.get_json怎麽用?Python Message.get_json使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Message
的用法示例。
在下文中一共展示了Message.get_json方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: send_msg
# 需要導入模塊: import Message [as 別名]
# 或者: from Message import get_json [as 別名]
def send_msg(self, target, data):
"""
Sends a message to a computer
@target: The ip address of the computer we are sending
the message to. This should be a string
@data: The data we are sending, usually the string representation
of JSON.
"""
# Get IP Address to populate message sender field
my_addr = NetworkUtilities.get_my_ip()
# Create a new message object
msg = Message(my_addr, target, data)
msg = msg.get_json()
# Create a new connection to the server
s = socket(AF_INET, SOCK_STREAM)
s.connect((self.host, self.port))
s.send(msg)
# Get response from server
response = s.recv(512)
print "Response from server : " + response
s.close()