fix socket message not sending

This commit is contained in:
Maxime Bloch 2019-09-27 17:43:33 +02:00
parent b4fd3f9710
commit c6e93f8c7f
No known key found for this signature in database
GPG key ID: CE32A7D95B7D6418

View file

@ -37,20 +37,20 @@ def start_run(run_index):
return f'Run {run_index} started at {starttime}'
@app.route("/link/start/<run>/<index>")
def link_start(run, index):
request_data = live_request(run, index)
@app.route("/link/start/<run>/<link_index>")
def link_start(run, link_index):
request_data = live_request(run, link_index)
sio.emit('live_request', request_data)
if db["current_run"] != run:
return "Wrong run number, check that you update your run", 404
else:
run_data = db["run_data"][run]["data"]
if index in run_data:
if link_index in run_data:
return "you already started in this run. Ignoring this request."
else:
run_data[index] = {"id": index, "start": time()}
sio.emit('link_start', run_data[index])
run_data[link_index] = {"id": link_index, "start": time()}
sio.emit('link_start', run_data[link_index])
return "Success."
@ -78,7 +78,7 @@ def connect(sid, data):
def live_request(run, index):
ip = request.remote_addr
request_data = {}
request_data["hostname"] = socket.gethostbyaddr(ip)
request_data["hostname"] = socket.gethostbyaddr(ip)[0]
request_data["time"] = time()
return request_data