Websocket multiple channels against one channel + server side [GroupChat]

Suppose we want to create private chats where a user can chat in small groups. A user can join several groups. In each case, I need to create a unique group on the server and subscribe to it. Which approach is recommended / more effective:


[1] On the server side, I create a room class and add new channel numbers for each group chat, for example. "chats / room-asdhqk1", "chats / room-fwuefhw1", "chats / room-awsdhqwd2". Now, some of the specified users can join this channel and are added to the group’s client list. On the client side, users subscribe to the groups to which they have been added.

Problem. When the user is in x-channels, I need to subscribe to these x-channels after side loading. Good: broadcasting to a specific group can be done by the name of the group channel, and all users who subscribe to this channel will automatically receive this message because they subscribed to the channel inside the js part.


[2] Each user receives his own channel , for example. "notifications / user-1", "notifications / user-2" .... On the server side, I create groups in the class of rooms (without channels). The user can be added to a specific room by adding it to the list of numbers. When they communicate with each other, the server iterates through a subscription of group chat users and sends each user a notification message — no group channel at all — only for user channels.

: , . , "publish" , , .

: , : . RPC-, , "publish" - . x , , .

( , (, zmq)).


? , , x-. , , , 500 .

.

+4

Source: https://habr.com/ru/post/1610232/


All Articles