Boost logo

Boost Users :

Subject: Re: [Boost-users] [Asio] How to implement a server and client that replies to all clients but one
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2018-03-20 22:43:17


On 18/03/2018 06:57, Gonzalo Garramuño wrote:
> Hi.  I want to have a variation on the chat server/client model in that
> there's a language with instructions being sent.
>
> Both the server and the client need to parse this language.  When the
> server changes something, it sends the change in the language to all
> clients.  When the client changes something it sends the change to the
> server which in turn resends it to all clients but, here's the catch,
> not to the one that sent the change in the first place.

When your server receives the change, it knows which client it was
received from (since it's received on that client's connection). When
you loop through the clients to forward the changes on, simply skip that
client instead of sending. (Or send it a confirmation or something
instead.)

Depending on how your code is structured, this might require you to pass
an identifier or pointer from the receiving connection down to the code
that forwards the changes, but it should be simple enough.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net