stash
This commit is contained in:
parent
26255fadec
commit
ed5b7aaca1
36 changed files with 1076 additions and 36 deletions
21
core/notify_sessions/decorators.py
Normal file
21
core/notify_sessions/decorators.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue