示例#1
0
    def post_receive(self, content, channel, participant_id):
        content['channel'] = channel
        content['participant_id'] = participant_id

        # in the Channels docs, the example has a separate msg_consumer
        # channel, so this can be done asynchronously.
        # but i think the perf is probably good enough.
        # moving into here for simplicity, especially for testing.
        nickname_signed = content['nickname_signed']
        nickname = Signer().unsign(nickname_signed)
        channel = content['channel']
        channels_group = get_chat_group(channel)

        body = content['body']
        participant_id = content['participant_id']

        chat_message = {
            'nickname': nickname,
            'body': body,
            'participant_id': participant_id
        }

        Group(channels_group).send({'text': json.dumps([chat_message])})

        ChatMessage.objects.create(participant_id=participant_id,
                                   channel=channel,
                                   body=body,
                                   nickname=nickname)
示例#2
0
    def post_receive(self, content, channel, participant_id):
        content['channel'] = channel
        content['participant_id'] = participant_id

        # in the Channels docs, the example has a separate msg_consumer
        # channel, so this can be done asynchronously.
        # but i think the perf is probably good enough.
        # moving into here for simplicity, especially for testing.
        nickname_signed = content['nickname_signed']
        nickname = Signer().unsign(nickname_signed)
        channel = content['channel']
        channels_group = get_chat_group(channel)

        body = content['body']
        participant_id = content['participant_id']

        chat_message = {
            'nickname': nickname,
            'body': body,
            'participant_id': participant_id
        }

        Group(channels_group).send({'text': json.dumps([chat_message])})

        ChatMessage.objects.create(
            participant_id=participant_id,
            channel=channel,
            body=body,
            nickname=nickname
        )
示例#3
0
 def group_name(self, channel, participant_id):
     return get_chat_group(channel)
示例#4
0
 def group_name(self, channel, participant_id):
     return get_chat_group(channel)