LoCo Day 13

The overhaul of the room code is done, at least for now. Instead of there being only one room on the server, now any number of them can exist. Woo.

I think the subscribe/unsubscribe logic is going to need a change at some point, since even with the light amount of testing so far, I’ve uncovered some design problems:

  • If you reload the room page, there’s a race condition between the unsubscribe request sent by the unload handler, and the request for the actual page. Whether or not the browser gets re-subscribed for messages or not depends on the order the server processes the messages. Worse, since a non-subscribed session trying to fetch a room’s message always returns an empty list immediately (since there’s nothing to wait on), the browser starts hammering the server with long-poll requests. Subscribing needs to be made more robust; perhaps the act of trying to fetch a room’s messages should count as a subscription request too.
  • On Chromium, the page’s unload handler either doesn’t fire or doesn’t manage to send the unsubscribe request in time. Either way, the unsubscribe never happens. Presumably there’s a flaw in my JavaScript code that does this, but even then I need to automatically unsubscribe sessions from rooms if there isn’t any activity after a little while, which will be needed anyway in case a client’s browser drops off the net one way or another.

I’ll need to fix all that eventually, but for now I think I ought to work on the actual game part of this game I’m supposed to be writing.

Comments Off