Thubrecht/daphne #815

Merged
thubrecht merged 39 commits from thubrecht/daphne into master 2024-07-30 18:40:56 +02:00
Showing only changes of commit 071c810605 - Show all commits

View file

@ -71,6 +71,9 @@ class DjangoJsonWebsocketConsumer(AsyncJsonWebsocketConsumer):
@classmethod
async def encode_json(cls, content):
# Remove the type value, only used by Channels to choose the group to send to
content.pop("type")
return json.dumps(content, cls=DjangoJSONEncoder)
@ -96,27 +99,3 @@ class PermConsumerMixin:
await super().connect()
else:
await self.close()
# async def raw_connect(self, message, **kwargs):
# # Same as original raw_connect method of JsonWebsocketConsumer
# # We add user to connection_groups call.
# groups = self.connection_groups(user=message.user, **kwargs)
# for group in groups:
# await self.channel_layer.group_add(group, message.reply_channel)
# # Group(group, channel_layer=message.channel_layer).add(message.reply_channel)
# self.connect(message, **kwargs)
#
# async def raw_disconnect(self, message, **kwargs):
# # Same as original raw_connect method of JsonWebsocketConsumer
# # We add user to connection_groups call.
# groups = self.connection_groups(user=message.user, **kwargs)
# for group in groups:
# await self.channel_layer.group_discard(group, message.reply_channel)
# # Group(group, channel_layer=message.channel_layer).discard(
# # message.reply_channel
# # )
# self.disconnect(message, **kwargs)
#
# def connection_groups(self, user, **kwargs):
# """`message.user` is available as `user` arg. Original behavior."""
# return super().connection_groups(user=user, **kwargs)