Answer the question
In order to leave comments, you need to log in
Django-channels: Why is a message sent to all users instead of just one?
Hello, tell me please.
I'm making a video chat with Django and WebRTC and I have a feature to set a user on hold.
The function works fine, the admin presses the button, a signal is sent to the user via the channel through the self.channel_layer.send() function, an alert() appears on the screen and he is put on hold.
However, when I release it from hold, a signal sent to the same address goes to all users, although the channel is the same as the previous time.
Hold function:
if action == 'onhold': # поставили на удержание
await self.channel_layer.send(
list(usersChannels.keys())[list(usersChannels.values()).index(message['peer'])], #канал на удержание
{
'type': 'channel_message',
'action': 'onhold',
'room': 'room',
'message': {message['peer']: '1'},
}
)
return
if action == 'unhold': # убрали с удержания
await self.channel_layer.send(
list(usersChannels.keys())[list(usersChannels.values()).index(message['peer'])],
{
'type': 'channel_message',
'action': 'unhold',
'room': 'room',
'message': {message['peer']: '1'},
}
)
return
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question