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)
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 )
def group_name(self, channel, participant_id): return get_chat_group(channel)