kpsul/kfet/consumers.py
Aurélien Delobelle 1e18c4043e Use last channels & co versions
- Use last official releases of channels, asgiref, daphne and
  asgi-redis packages.
- Customization of JsonWebsocketConsumer is now in kfet app through a
  custom class (and so, doesn't require anymore a forked version of channels).
- Clean kfet consumers code.
2017-04-09 15:47:16 +02:00

22 lines
488 B
Python

# -*- coding: utf-8 -*-
from django.core.serializers.json import json, DjangoJSONEncoder
from channels.generic.websockets import JsonWebsocketConsumer
class DjangoJsonWebsocketConsumer(JsonWebsocketConsumer):
"""Custom Json Websocket Consumer.
Encode to JSON with DjangoJSONEncoder.
"""
@classmethod
def encode_json(cls, content):
return json.dumps(content, cls=DjangoJSONEncoder)
class KPsul(DjangoJsonWebsocketConsumer):
groups = ['kfet.kpsul']