Hello. Made a client server chat in C #, now there is a task to implement a private room.

  1. How to make the entrance to the room?
  2. How to make messages from customers who are in the room displayed only in this room or how to share these rooms on the server so that all the rooms and the general chat are independent?

    1 answer 1

    If a room is identified by its internal number, you can do the following:

    1. Match server side:
      • each user has an unordered set of numbers of rooms in which he is located,
      • each message - the number of the room in which it was published.
    2. When a new message appears on the server, send it only to those users who have the same number in the above set as the message.
    3. After connecting the client to the server, send the first pair of โ€œroom number โ€” additional parameters of the room (name, etc.)โ€.