1
0
Derivar 0

Add some recovery attempts for race condition of missing status invalidation.

feature/long-poll-status
Daniel Perelman há 4 anos
ascendente 93e521aca0
cometimento 564d79e831

@ -158,6 +158,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
@ -343,6 +349,11 @@ class StatusLongPollConsumer(AsyncHttpConsumer):
await self.channel_layer.group_add("%s_status" % self.access_code,
self.channel_name)
await self.channel_layer.group_send(
"%s_status" % self.access_code, {
"type": "fear_tracker.hashcode_seen",
"hashcode": self.hashcode,
})
async def http_request(self, message):
"""
@ -358,6 +369,13 @@ class StatusLongPollConsumer(AsyncHttpConsumer):
await self.channel_layer.group_discard("%s_status" % self.access_code,
self.channel_name)
async def fear_tracker_hashcode_seen(self, event):
if self.hashcode != event["hashcode"]:
await self.channel_layer.group_send(
"%s_status" % self.access_code, {
"type": "fear_tracker.invalidate_status",
})
async def fear_tracker_invalidate_status(self, event):
no_hash_status = reverse('status',
kwargs={'access_code': self.access_code})

Carregando…
Cancelar
Guardar