More Token Library Updates
If you're interested in some technical discussion, let's talk about sharing images over TCP!
Right now there's a problem in Isocon, which is that sharing images between clients, especially large clients, gets dicey. The networking code uses TCP and is limited in how much data it can send in a single request. So for images, you can't simply send an entire 2MB png in a single request. What you can do is break it into 512 byte chunks and send those, one after the other. I didn't encounter any issues while testing this, even when simulating multiple connections, even with simulated latency. But in real world scenarios, it's entirely possible, nay inevitable that packet loss will occur, causing a piece to be missing, and the token-receiver client to flood the token-sender client with requests, which spikes the memory use of the token-sender, causing a disconnect, or the app to freeze, or even crash.
So I've been rebuilding this system, because if you can't share tokens, the VTT isn't very useful.
In the new version, a client who is missing a token will notify the host, who will pass a list of the missing chunks to the other clients. Any client who has the token will then send up to 10 random chunks to the host, who will then pass those chunks to all clients.
Why all clients? Because a very common real-world scenario is that one player will create a new token, which all other players, including the host, will then all need to sync at the same time. So consider: a player (A) connected as a client creates a token with 100 chunks (ie, a 5kb image), which needs to be shared with 2 other players (B and C), while a fourth player already has the image from a previous session with A. All players receive the token's meta information right away, including number of chunks and image height/width/etc.
- BC notify the host which chunks they're missing (at the outset, 1-100)
- Host tells ABCD to send up to 10 tokens
- A sends chunks 3, 45, 82, and 77 to host
- BC send nothing
- D sends chunks 5, 65, 23, 90 to host
- Host sends chunks 3, 45, 82, 77, 5, 65, 23, 90 to all clients
- AD ignore the chunks, BC receive chunks
- After a timed interval, the process repeats until all chunks are received
I only got this process working right before I stopped working last night, so it still needs some testing. For one, the likelihood of sending repeat data increases as the number of missing chunks decreases. It might be possible at step 2 to specify certain clients to send certain chunks, but the host doesn't know without making additional requests whether a client has the image. An additional persistent data layer could solve this, but it might introduce unwarranted complexity.
Testing happens tonight!
Get IsoCON
IsoCON
3d virtual tabletop for tactical combat skirmish/TTRPGs
More posts
- Games for Freaks Maleghast Update13 days ago
- v0.7.4 ReleasedMay 28, 2024
- v0.7.3 ReleasedMar 31, 2024
- v0.7.2 ReleasedMar 24, 2024
- v0.7.1 ReleasedFeb 18, 2024
- v0.7 ReleasedFeb 17, 2024
- Token LibraryFeb 07, 2024
- Update on 0.6.9Feb 05, 2024
- HousekeepingFeb 01, 2024
Leave a comment
Log in with itch.io to leave a comment.