18 lines
430 B
Python
18 lines
430 B
Python
|
|
import json
|
|
from channels.generic.websocket import WebsocketConsumer
|
|
from asgiref.sync import async_to_sync
|
|
|
|
|
|
class WsConsumer(WebsocketConsumer):
|
|
def connect(self):
|
|
self.accept()
|
|
print("accept ws connection")
|
|
|
|
def disconnect(self, close_code):
|
|
print("ws disconnection")
|
|
|
|
def receive(self, text_data):
|
|
text_data_json = json.loads(text_data)
|
|
print("ws receive", text_data_json)
|