I'm trying to send messages to channels outside of consumers, as said in documentation but can't get a result.
For example,
in consumers.py I have:
def channel_send(channel, data):
channel.send({
'text': json.dumps(data)
})
def group_send(kind, data):
data = {
'kind': kind,
'data': data
}
channel_send(Group(kind), data)
def ws_connect(message):
Group("location_update").add(message.reply_channel)
channel_send(message.reply_channel, {'accept': True})
group_send('location_update', {'msg': 'connected'})
def ws_disconnect(message):
# Remove from reader group on clean disconnect
Group("location_update").discard(message.reply_channel)
def ws_message(message):
group_send('location_update', {'msg': 'connected'})
When I send message from browser over websocket, I got a response in console:
{"kind": "location_update", "data": {"msg": "connected"}}
but, for example, when I try to use group_send function inside management command, or if I try to use group_send in python manage.py shell regime from shell - I don't get anything in the browser
channels==1.0.1
What may be the issue?