forcecraft/aion

fix(elixir): Set up the timers outside of the channels

Opened this issue · 0 comments

Type

Bug

Current behaviour
The timers are set up as :timer.send_after in channels/room. The problem is that if the first user joins the room and leaves it, the timer gets cancelled.

Expected behaviour
The timers shouldn't depend on people joining or leaving the room (apart from the case when the room is closed).

The timers could be implemented using quantum, but I guess it would end up being really hacky.

Instead I think we may just introduce a GenServer that will be called whenever a question is changed (we could also transform QuestionChronicle to be sort of RoomStateGuard), which would invoke the broadcast/3 function and the sockets would handle it accordingly.

I think it would actually be a good idea architecture-wise - making the whole game operate in socket area only does not seem to be very stable.

Motivation / use case
Unbugging