Compare commits

..

No commits in common. "59045a199d065a499568b7ca0395f666e9226f9e" and "0b4beea4913391bff7c86585ed5f98b7833d66b4" have entirely different histories.

2 changed files with 13 additions and 24 deletions

View File

@ -392,10 +392,9 @@
statusObj = data;
}
})
.then(checkStatus)
.catch(() => {
// If something went wrong, wait a few seconds before retrying.
setTimeout(checkStatus, 5000);
.catch(() => {})
.then(() => {
checkStatus();
});
}
checkStatus();

View File

@ -159,6 +159,12 @@ def game_status_object(game, current_phase=None, players_with_fear=None):
status_hash = h.hexdigest()
status_obj['hash'] = status_hash
async_to_sync(get_channel_layer().group_send)(
"%s_status" % game.access_code, {
"type": "fear_tracker.hashcode_seen",
"hashcode": status_hash,
})
return status_obj
@ -284,6 +290,10 @@ def handle_game_request(request, game, update):
for player in players.values():
player.ready = True
async_to_sync(get_channel_layer().group_send)(
"%s_status" % game.access_code,
{"type": "fear_tracker.invalidate_status"})
if update:
if errors:
res = {
@ -294,22 +304,12 @@ def handle_game_request(request, game, update):
res['value'] = current_value
else:
res = {'success': True}
async_to_sync(get_channel_layer().group_send)(
"%s_status" % game.access_code,
{"type": "fear_tracker.invalidate_status"})
return HttpResponse(json.dumps(res))
players = get_players_with_fear(game, current_phase, players)
status_obj = game_status_object(game, current_phase, players)
status_string = json.dumps(status_obj)
async_to_sync(get_channel_layer().group_send)(
"%s_status" % game.access_code, {
"type": "fear_tracker.hashcode_seen",
"hashcode": status_obj['hash'],
"status_string": status_string,
})
for player in players.values():
info = player.fear
if not info:
@ -340,12 +340,6 @@ def status(request, game, hashcode=None):
return HttpResponse(status=HTTPStatus.NOT_MODIFIED)
else:
status_string = json.dumps(status_obj)
async_to_sync(get_channel_layer().group_send)(
"%s_status" % game.access_code, {
"type": "fear_tracker.hashcode_seen",
"hashcode": status_obj['hash'],
"status_string": status_string,
})
return HttpResponse(status_string)
@ -378,10 +372,6 @@ class StatusLongPollConsumer(AsyncHttpConsumer):
async def fear_tracker_hashcode_seen(self, event):
if self.hashcode != event["hashcode"]:
if event["status_string"]:
body = event["status_string"].encode('utf-8')
await self.send_response(200, body)
await self.disconnect()
await self.channel_layer.group_send(
"%s_status" % self.access_code, {
"type": "fear_tracker.invalidate_status",