Users with a 1.5mbps connection who persistently attempt to connect with other users can be quite frustrating. They often fail to read and understand why the connection is not working for them. Unfortunately, their actions end up ruining the experience for other players... 🫤
Apparently, it is possible to know the connection speed between users using peerjs:
Latency Measurement: You can measure the time it takes for data to be sent from one peer to another and calculate the latency. This can give you an indication of the responsiveness of the connection. You can use timestamps to measure the round-trip time for small packets of data.
Bandwidth Measurement: You can estimate bandwidth by measuring the time it takes to transfer a known amount of data between peers. For example, you can send a large file and measure the time it takes to transfer it. Then, divide the file size by the transfer time to get an estimate of the bandwidth.
Network Information API: You can use the Network Information API (available in modern browsers) to gather information about the user's network connection. This API provides properties such as navigator.connection.downlink and navigator.connection.rtt that give you information about the effective bandwidth and round-trip time of the connection.
Third-Party Services: There are also third-party services and libraries available that specialize in measuring connection speed and quality, such as Speedtest.net's API. You could integrate these services into your application to measure connection speed between peers.
At least, I'm going to start by adding simple rules to follow, such as:
DO NOT PLAY FROM PUBLIC WIFI