Wednesday, April 26, 2017

Re: Multiplex results from (Django-Channels)

Yep I do appreciate the limited advice that you're able to give here- I'm trying to learn, and this is for a community project. 

So, I've attempted to put it in a for loop as suggested, but still I'm not seeing the result.

@channel_session
def ws_connect(message):
    listrooms
= User.objects.filter(chat__isnull=False).values('chat')
   
# `listrooms` gives the PK fields of the chat rooms
    chathistory
= room.messages.all().order_by('timestamp')
       
for listrooms in message.channel_session.get("rooms", set()):
           
try:
                room
= Room.objects.get(pk=room_id)
               
Group('chat-' + listrooms).add(message.reply_channel)
                message
.reply_channel.send({'text': json.dumps([msg.as_dict() for msg in chathistory.all()])})
           
except KeyError as e:
               
print str(e)
               
pass

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/50d21f1e-8fbf-4c97-ab96-60fe0c5b9b1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment