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.
This commit is contained in:
Aurélien Delobelle 2017-04-09 15:47:16 +02:00
parent 15861824b6
commit 1e18c4043e
2 changed files with 15 additions and 20 deletions

View file

@ -1,26 +1,21 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division,
print_function, unicode_literals)
from builtins import *
from django.core.serializers.json import json, DjangoJSONEncoder
from channels import Group
from channels.generic.websockets import JsonWebsocketConsumer
class KPsul(JsonWebsocketConsumer):
# Set to True if you want them, else leave out
strict_ordering = False
slight_ordering = False
class DjangoJsonWebsocketConsumer(JsonWebsocketConsumer):
"""Custom Json Websocket Consumer.
def connection_groups(self, **kwargs):
return ['kfet.kpsul']
Encode to JSON with DjangoJSONEncoder.
def connect(self, message, **kwargs):
pass
"""
def receive(self, content, **kwargs):
pass
@classmethod
def encode_json(cls, content):
return json.dumps(content, cls=DjangoJSONEncoder)
def disconnect(self, message, **kwargs):
pass
class KPsul(DjangoJsonWebsocketConsumer):
groups = ['kfet.kpsul']