22 lines
535 B
Python
22 lines
535 B
Python
|
from asgiref.sync import async_to_sync
|
||
|
from channels.layers import get_channel_layer
|
||
|
|
||
|
|
||
|
def notify_sessions(event, data):
|
||
|
def wrapper(func):
|
||
|
def wrapped(*args, **kwargs):
|
||
|
ret = func(*args, **kwargs)
|
||
|
channel_layer = get_channel_layer()
|
||
|
async_to_sync(channel_layer.group_send)(
|
||
|
event,
|
||
|
{
|
||
|
'type': 'notify',
|
||
|
'data': data,
|
||
|
}
|
||
|
)
|
||
|
return ret
|
||
|
|
||
|
return wrapped
|
||
|
|
||
|
return wrapper
|