コード例 #1
0
ファイル: views.py プロジェクト: kanu/django_longpolling_demo
    def post(self, request, *args, **kwargs):
        try:
            client = session_manager.get(request.META['HTTP_SESSION_ID'])
        except (KeyError, InvalidSessionId):
            return HttpResponse(status_code=400)

        session_manager.send_beep(client)

        return HttpResponse("ok")
コード例 #2
0
    def post(self, request, *args, **kwargs):
        try:
            client = session_manager.get(request.META['HTTP_SESSION_ID'])
        except (KeyError, InvalidSessionId):
            return HttpResponse(status_code=400)

        session_manager.send_beep(client)

        return HttpResponse("ok")
コード例 #3
0
ファイル: views.py プロジェクト: kanu/django_longpolling_demo
    def post(self, request, *args, **kwargs):
        try:
            client = session_manager.get(request.META['HTTP_SESSION_ID'])
        except (KeyError, InvalidSessionId):
            name = names.get_full_name()
            client = session_manager.create_client(name)

            return HttpResponse(dumps({"SESSION_ID": client.session_id, "client": client.data}))

        try:
            acks = loads(request.body).get("acks") or []
        except Exception:
            raise Exception(request.body)
            logger.exception(request.body)

            acks = []

        return HttpResponse(dumps({'messages':client.get_messages(acks)}), content_type='application/json')
コード例 #4
0
    def post(self, request, *args, **kwargs):
        try:
            client = session_manager.get(request.META['HTTP_SESSION_ID'])
        except (KeyError, InvalidSessionId):
            name = names.get_full_name()
            client = session_manager.create_client(name)

            return HttpResponse(
                dumps({
                    "SESSION_ID": client.session_id,
                    "client": client.data
                }))

        try:
            acks = loads(request.body).get("acks") or []
        except Exception:
            raise Exception(request.body)
            logger.exception(request.body)

            acks = []

        return HttpResponse(dumps({'messages': client.get_messages(acks)}),
                            content_type='application/json')