|
@ -6,6 +6,7 @@ class PainelConsumer(WebsocketConsumer): |
|
|
def connect(self): |
|
|
def connect(self): |
|
|
self.channel_layer.group_add('message', self.channel_name) |
|
|
self.channel_layer.group_add('message', self.channel_name) |
|
|
self.accept() |
|
|
self.accept() |
|
|
|
|
|
self.send('Teste') |
|
|
|
|
|
|
|
|
async def disconnect(self, close_code): |
|
|
async def disconnect(self, close_code): |
|
|
await self.channel_layer.group_discard('message', self.channel_name) |
|
|
await self.channel_layer.group_discard('message', self.channel_name) |
|
@ -18,8 +19,8 @@ class PainelConsumer(WebsocketConsumer): |
|
|
self.send(text_data=json.dumps({ |
|
|
self.send(text_data=json.dumps({ |
|
|
'message': message |
|
|
'message': message |
|
|
})) |
|
|
})) |
|
|
|
|
|
|
|
|
async def send(self, event): |
|
|
async def send_message (self, event): |
|
|
new_data = event['text'] |
|
|
new_data = event['text'] |
|
|
print(new_data) |
|
|
print(new_data) |
|
|
await self.send(json.dumps(new_data)) |
|
|
await self.send(json.dumps(new_data)) |