本文整理汇总了Python中flask_socketio.SocketIO.debug方法的典型用法代码示例。如果您正苦于以下问题:Python SocketIO.debug方法的具体用法?Python SocketIO.debug怎么用?Python SocketIO.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask_socketio.SocketIO
的用法示例。
在下文中一共展示了SocketIO.debug方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: receiving_sensor_update
# 需要导入模块: from flask_socketio import SocketIO [as 别名]
# 或者: from flask_socketio.SocketIO import debug [as 别名]
def receiving_sensor_update(json):
print('sensor says: ' + str(json))
# this will come from client
@socketio.on('atime')
def atime(message):
print('sensor says: ' + str(message))
emit('atime', message, broadcast=True)
# this will come from client
@socketio.on('JSON')
def JSON(json):
print('sensor says: ' + str(json))
emit('JSON', json, broadcast=True)
if __name__ == '__main__':
socketio.debug = False
socketio.run(app, host='0.0.0.0', port=1234)
示例2: emit
# 需要导入模块: from flask_socketio import SocketIO [as 别名]
# 或者: from flask_socketio.SocketIO import debug [as 别名]
emit("character_sheet_sync", character_sheet)
# this will come from client
@socketio.on("status_update_request")
def status_update_request(json):
status_json = {"id": character_sheet["id"], "status": character_sheet["status"]}
emit("status_sync", status_json)
# this will come from client
@socketio.on("sync_section_by_key")
def sync_section_by_key(json):
if "section_key" in json:
# if they sent data, save it to server
if "data" in json:
# save data to server
pass
# always respond with data fragment
json = {
"id": character_sheet["id"],
"section_key": json["section_key"],
"data": character_sheet[json["section_key"]],
}
emit("sync_section_by_key", json)
if __name__ == "__main__":
socketio.debug = True
socketio.run(app)