Suppose, for example, what is the messenger — he's a server and client. Each client connection is done in a separate thread (QThread). Every client has a unique identifier (e.g., e-mail address of the owner).
I realize transmission of messages from one client to another is now: each thread subscribes to a signal from the server. When one client sends a message, the server emits the signal and all the threads look at the ID of the client — the trade unions, with whom he coincides with the destination, sends the message to the client. Everything is simple and works fine, but I have a suspicion that this is somewhat wrong. What if customers millions? Maybe there's a smarter way?
PS Every thread also has a unique numeric ID, assigned automatically upon creation. You can write to the database this ID and mailing address. But again — how to send the signal to trade with a specific ID?