c3lf-system-3/core/notify_sessions/decorators.py
2024-11-20 02:44:06 +01:00

21 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