c3lf-system-3/core/notify_sessions/decorators.py
2024-11-23 01:35:29 +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