From c00efa088456787e4c10fcfb75e6ffd4874c4c41 Mon Sep 17 00:00:00 2001 From: Marks Polakovs Date: Fri, 17 Apr 2020 10:10:40 +0200 Subject: [PATCH] Fiddle --- stateserver.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/stateserver.py b/stateserver.py index 95e68ec..b1500e1 100755 --- a/stateserver.py +++ b/stateserver.py @@ -254,11 +254,6 @@ def post_registerCheck() -> Any: if not found_credit: return genFail("You are not authorised to broadcast for this timeslot.") - for conn in connections: - if content["timeslotid"] == conn["timeslotid"]: - # they've already registered, return the existing session - return genPayload(conn) - start_time = datetime.datetime.strptime(timeslot["start_time"], "%d/%m/%Y %H:%M") duration = timeslot["duration"].split(":") @@ -267,6 +262,21 @@ def post_registerCheck() -> Any: end_time = start_time + duration_time now_time = datetime.datetime.now() + + for conn in connections: + if content["timeslotid"] == conn["timeslotid"]: + # they've already registered, return the existing session + # but first, check if it has a nulled-out wsID + # TODO: duplicate of fragment below + if "wsid" in content: + conn["wsid"] = content["wsid"] + if start_time + datetime.timedelta(minutes=2) < now_time: + # they're late, bring them live now + print("({}, {}) rejoined late, bringing on air now".format(conn["connid"], conn["wsid"])) + do_ws_srv_telnet(conn["wsid"]) + subprocess.Popen(['sel', '5']) + return genPayload(conn) + if start_time - now_time > datetime.timedelta(hours=1): return genFail("This show too far away, please try again within an hour of starting your show.")