BlankParenthesis / PxlsNetworking

Working draft of the next Pxls networking specifcation
0 stars 0 forks source link

Clients must manually request user counts #4

Open BlankParenthesis opened 3 years ago

BlankParenthesis commented 3 years ago

This seems contentious despite me personally thinking it's fine so I'm opening this issue to discuss it.

The proposed solution is to add a websocket packet which notifies clients of the current user count.

Benefits to adding an event

If clients frequently use the data, they either have to make many requests or deal with stale data:

By adding an event, the server can decide how frequently it wants to update this information. This allows it to save bandwidth where needed.

Websocket packets are more efficient for bandwidth in general than an HTTP packet, especially if the client has to poll more frequently than the value changes.

Downsides to adding an event

The server does not know when the client wants to use the data.:

Servers already have mechanisms for controlling bandwidth - rate limits.

Polling an unchanging value has very little overhead - HTTP implements effective caching of requests.

Adding an event adds complexity in the client, server, and the specification.

netux commented 3 years ago

Downside: The server does not know when the client wants to use the data

If the client wants to receive this information, we can implement a system where the client can signal this to the server. For example, we can make use of a query parameter on the /ws endpoint, or use a subscription system through packets just like chatrooms are implemented.

BlankParenthesis commented 3 years ago

That would be an option, but the style of such a solution would mean the most consistent way to integrate it is with an extension. I'm not entirely against that, but it would feel like a very small extension.