Build this kind of game
Let a player who lost connection come back to their own seat
Wi-Fi drops, a phone switches networks, a laptop sleeps for a minute. If the game removes the player at once, the team loses a member for nothing; if it waits forever, a dead seat blocks the room. Here is a waiting time that works and how the returning player proves who they are.
Stop one player from flooding the game with moves or actions
A modified client, or just a browser tab coming back from sleep, can send hundreds of actions in one go and move a character far beyond what is fair. A strict limit per second blocks honest bursts too. Here is the allowance idea that blocks floods but forgives a hiccup.
Open a shared world save from an older version without losing anyone
After an update, the world your friends built last week must still open. Saves written by older versions have a different shape, and a broken or hand-edited file can hold impossible values. Here is a loader that upgrades old files step by step, repairs what it safely can and refuses what it must not guess.
Keep my own character smooth online without being pulled back by the server
In an online game your character should react at once, yet the server has the last word. If you handle the server's answer naively, your figure jerks backwards or jitters on every step. Here is how the answer is merged with what you already did, so movement stays calm.
Resend an unanswered message without flooding a struggling connection
When an important message gets no answer, sending it again at once and again makes a bad connection worse, and giving up too early drops players for a hiccup. The waiting time between tries should grow, start from the real delay, and not line up for everybody. Here are the numbers and when to stop.
Make room codes that friends can read out loud and type without mistakes
Friends join your game by a short code they get over voice chat or a text message. If the code can be confused or two rooms get the same one, someone ends up in the wrong game. Here is how to build codes that survive being read aloud, and what to do with a typo.
Generate the same world for every player from one shared number
Sharing a single number instead of the whole world saves a lot of traffic, but it only works if every machine draws the same random values in the same order. One extra random call on one side, such as for a particle, shifts everything after it. Here is the way to split the randomness so that cannot happen.
Send only what changed about the world, and recover when a packet is lost
Sending the whole world sixty times a second is wasteful, but sending only changes breaks as soon as one packet goes missing, and the player sees a world that is slightly wrong forever. The trick is to compare against what the player has confirmed, not against what you sent last. Here is how, with the fallback.
Get all players onto the same game clock so timed events line up
A boss that wakes up at a set moment or a countdown that ends for everyone together needs a shared sense of time, but every device's clock is a little different. Averaging ping answers looks natural and is wrong. Here is which answer to trust and how to move the clock without visible jumps.
Tell each player only about things nearby, without things blinking at the edge
In a big shared world, telling every player about everything wastes traffic and lets cheaters see through walls. Sending only what is near works, until something stands right on the border and appears and vanishes every other step. Here is a rule with two different distances that stops the blinking, and a cap for crowded places.
Make other players glide instead of teleporting in an online game
Other players arrive as a few position updates per second, so drawing them as they come makes them hop. Showing them a little late and blending between updates fixes it, but guessing ahead too long makes them run through walls. Here is the balance and what to do when updates stop.
Stop friends on different game versions from joining each other and breaking things
After an update, some players have the new version and some still have the old one, and mixing them leads to odd bugs instead of a clear message. A version check at the door can tell people exactly what to do. The catch is that comparing version texts the obvious way gives wrong answers.