I've been developing LightnerX, an open-source C++ networking library for multiplayer games, and one of the things I've spent time working on is how messages are sent to connected clients.
It sounds simple at first. You have a message, you have a connection, and you send it.
But multiplayer applications don't always need to send messages to just one client.
Sometimes you want to send something to a specific player. Sometimes to a group of players. And sometimes to everyone connected to the server.
I wanted LightnerX to handle these cases through a consistent interface.
The Target abstraction
In LightnerX, I introduced an abstraction called Target .
It represents the intended recipients of an outgoing message.
There are three delivery modes:
Single: Send a message to one specific connection.
Group: Send a message to a selected group of connections.
Broadcast: Send a message to all applicable connected clients.
Consider a multiplayer game where players are divided into teams.
If a player receives…