This is handled by what some networking APIs call "ghosting". When a player's position changes it marks a flag (boolean or bit) dirty, and periodically (every 300-500ms or so) the networking system will grab all information that has been marked dirty and send it to every player that is in range of the player whose information is dirty. Additionally, whenever a player comes in range of another player, both of those players are sent the entirety of each others information (only the info that they need to know about each other, such as position, or rotation).
Here's some more information I've written about ghosting:
An example of this. Let's imaging there are 2 players in range of each other (Players #1 and #2), and a 3rd player just out of range (Player #3).
- Player #1 moves around a bit. This marks his position as being dirty, the networking system records this change.
- Sometime in the next few hundred milliseconds, the networking system goes through all dirty flags it finds, and finds that Player #1's position is marked dirty. It then adds that information, and any other information about player #1 to a packet and sends a copy of that packet to any player in range.
- Player #2 receives the packet and updates the information that it has for player #1. Generally prediction algorithms come into play here so that player #1 doesn't just teleport to the new known position, but rather interpolates towards it over time.
- Player #3 walks into range of player #1 and player #2.
- The networking system sees that player #1 and #2 are new to player #3, and player #3 is new to player #1 and #2, so it sends player #3 all of the necessary information from player #1 and #2, and sends them player #3's information as well.
Any player that leaves range results in a message to other players that had the player in range, so that they may remove them from their client. Generally the client will keep information about a player leaving range around for about 30 seconds in the case that the player continues to enter and leave range, so the server doesn't have to continuously send down all of that player's information every time the player re-enters range.