Skip to content

Instantly share code, notes, and snippets.

@goltsevnet
Last active February 26, 2019 12:22
Show Gist options
  • Select an option

  • Save goltsevnet/aec19c62e134c0417fbea8556c1477c0 to your computer and use it in GitHub Desktop.

Select an option

Save goltsevnet/aec19c62e134c0417fbea8556c1477c0 to your computer and use it in GitHub Desktop.
class BalanceConsumer(AsyncWebsocketConsumer):
async def connect(self):
self.user = self.scope['user']
if self.user.is_authenticated:
# text_data = json.dumps({
# 'message': '99999999'
# })
self.user_name = str(self.user.username)
await self.channel_layer.group_add(
self.user_name,
self.channel_name
)
print('пробуем выслать')
await asyncio.sleep(5)
await self.channel_layer.group_send(
self.user_name,
self.channel_name,
{
'type': 'user_name',
'message': 'test'
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment