R
R
Roman Rakzin2017-10-11 22:37:25
C++ / C#
Roman Rakzin, 2017-10-11 22:37:25

How to handle events for chat in C#?

I want to implement chat rooms, and let's say, in room 5 and someone writes to room 5, then generate an event and send it to all users of the room. That is, do not send it to everyone, and then check if he is in the room, but send it directly to the room. More precisely, if user 1 is in room 5, then he subscribes to the event of receiving a new message, but not for everyone, but for room 5.
How can I implement this?
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Peter, 2017-10-12
@petermzg

This is already implemented, you can use Google Cloud Pub/Sub
Where message - Message
Room - topic
User - subscriber

L
LiptonOlolo, 2017-10-13
@LiptonOlolo

In general, this is done on the server side, not on the client side.
You can do it like this: Dictionary<Room, User[]>
And send received messages only to those who are in this room.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question