Update base consumers

This commit is contained in:
Tom Hubrecht 2022-06-28 15:59:05 +02:00 committed by thubrecht
parent 7f00ce0ff1
commit 071c810605

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)