Closed goldalworming closed 13 years ago
chage def on_new_messages(self, messages):
if self.request.connection.stream.closed():
return
self.finish(dict(messages=str(messages.body)))
and it's done
@goldalworming Hey I am trying to achieve the same long polling chat with brukva/pub-sub but its lack of documentation and I see you stuck in same place with passing callback objects in long polling, do you have any code examples about it ?
I was successfully make pub sub work as I wish...but unfortunately my code was cleaned up while I installing new linux... if you don't mind, let me see your code...maybe I could help..
Pada 10 Desember 2011 19:32, Burak Dede < reply@reply.github.com
menulis:
@goldalworming Hey I am trying to achieve the same long polling chat with brukva/pub-sub but its lack of documentation and I see you stuck in same place with passing callback objects in long polling, do you have any code examples about it ?
Reply to this email directly or view it on GitHub: https://github.com/evilkost/brukva/issues/13#issuecomment-3090615
Here is part of my code. https://gist.github.com/1455409
"listing_id" will be the channel name that user subscribe but I dont know how to write "wait_for_messages" and "new_messages" in MesssageMixin class.
@goldalworming any chance you can look at code sample ? sorry for the rush I need to have it done fast.
I'm sorry I was totally lost my code...but something I can tell you is I didn't really need messagemixin anymore while using burkva..
it was just asynchronously fetch the new messages in redis.
Pada 10 Desember 2011 23:09, Burak Dede < reply@reply.github.com
menulis:
@goldalworming any chance you can look at code sample ? sorry for the rush I need to have it done fast.
Reply to this email directly or view it on GitHub: https://github.com/evilkost/brukva/issues/13#issuecomment-3091503
thats a good news using with redis MessageMixin seems just extra anyway. any change in javascript side of the chat.js ?
is it appropriate to initiate connection to redis everytime like in the MessageUpdateHandler just like you did ? Seems like one connection fits fine...
chat.js update is depend on your need,
I little forgot about create connection to redis while message handler...but the clue is just follow the code like burkva example
Pada 10 Desember 2011 23:56, Burak Dede < reply@reply.github.com
menulis:
is it appropriate to initiate connection to redis everytime like in the MessageUpdateHandler just like you did ? Seems like one connection fits fine...
Reply to this email directly or view it on GitHub: https://github.com/evilkost/brukva/issues/13#issuecomment-3091701
@burakdd this is the code, I rewrite it for example
@goldalworming thanks I checked your code, you have to call "unsubscribe" after calling finish cause you probably get error below cause its sendin empty post return for the first time and then callback executed and call finish again so better unsubscribe client there. I am also looking if it is right way to connect new client each time new post call cause when I check redis console its adding 7 client even 2 connected and sended 2 messages... But thanks for the code again.
"""RuntimeError: finish() called twice. May be caused by using async operations without the @asynchronous decorator. [E 111212 00:51:02 web:657] Cannot send error response after headers written"""
@burakdd I am very pleased to know how you solve it.
I'm trying to make long polling from asynchronous brukva pubsub but got error this error in implement tornado chat example
but i got these error