RutgersGRID / hubs

Duck-themed multi-user virtual spaces in WebVR. Built with A-Frame.
https://hubs.mozilla.com
Mozilla Public License 2.0
0 stars 0 forks source link

Query number of people currently in rooms #35

Open yalegria opened 2 years ago

Voxelghiest commented 1 year ago

Originally, I thought that querying the number of people currently in a given room would be the same as querying other room statistics: Accessing the ret_dev database and using information from the hubs table (which contains room information).

However, it turns out that it's slightly more complicated than that. The Phoenix library, which Reticulum uses to manage the various room connections, uses a Presence framework to track the number of connections to each socket (room). The documentation on how the Presence system stores information on the number of active connections is confusing so far, but I plan to take a closer look and figure out what kind of database query should be made to access the room occupancy information.

Voxelghiest commented 1 year ago

I believe that there are two options that we have in order to gain access to the room occupancy information from Hubs Admin:

  1. Add a custom Presence.fetch/2 handler function in Reticulum's presence.ex code that inserts the presence information into the database as part of the hubs table mentioned earlier, then read that information from Hubs Admin normally
  2. Use the client-side JavaScript API for the Phoenix library to connect to Reticulum directly and query the presence info (as demonstrated here)