本文整理汇总了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()