mbari-org / lcm-websocket-server

WebSocket server for republishing LCM messages.
3 stars 0 forks source link

Open connections? #6

Open carueda opened 1 year ago

carueda commented 1 year ago

Hi @kevinsbarnard

Just a suggestion, not critical at all but potentially useful, and perhaps not difficult to implement (I would have gone with a PR already, but I'm less familiar with websockets in python and time is scarce):

Have the server report:

I have functionality like the above for the Dash, and this has been very useful specially for monitoring performance, see actual use of the system at any given moment, and the like.

kevinsbarnard commented 1 year ago

Hi @carueda

synchronously, that is, via regular http request:

I've added a rudimentary HTTP server alongside the WebSocket server. See the http-server branch if you want to give it a spin -- it runs on 1 + the specified port and just returns a JSON blob with the number of connected clients for a GET request on any path. I also reworked logging a tiny bit so you can change verbosity from the command line.

asynchronously, that is, via websocket event (as any other, but with some special metadata_ prefix or something for the name of the event):

I'm hesitant to implement the async reporting of clients connecting/disconnecting as it would muddy the schema a bit (clients would need to know about this special case). Maybe a separate endpoint for this to opt-in would suffice, but I need to think about this more (time is also scarce on my end).

carueda commented 1 year ago

Hi @kevinsbarnard, thanks, great progress; again, this is just a nice-to-have, as-time-permits kind of thing. Appreciate the effort!