Re: Django AJAX polling: Best practice?

2011-07-22 Thread Shawn Milochik

On 07/22/2011 02:35 AM, PyPal wrote:

Hi Shawn,

I think you were referring to the APE ( http://www.ape-project.org/ )
framework as the 'gorilla' thingy...




Yes, thanks! I did some Google searching but couldn't find it. Someone 
on the list said they were going to give it a shot, but I haven't heard 
of anyone using it in production yet.


I think I'll give them another look also. I have a Hookbox project 
half-finished that I haven't had time to go back to. It's long overdue.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django AJAX polling: Best practice?

2011-07-22 Thread PyPal
Hi Shawn,

I think you were referring to the APE ( http://www.ape-project.org/ )
framework as the 'gorilla' thingy...


On Jul 3, 8:01 am, Shawn Milochik  wrote:
> On 07/01/2011 05:05 PM, Andreas Pfrengle wrote:
>
> > Thanks so far for showing me that I was on the completely wrong
> > track ;-)
>
> > I found that there is really not much official information available
> > about Hookbox:. That doesn't make an easy
> > decision for Hookbox.
>
> > Has anyone experience with socket.io and gevent instead? Looks
> > interesting at first glance:
> >  > and-gevent/>
> > 
>
> There are other options, such as Orbited, and another on I can't
> remember the name of but I think 'gorilla' had something to do with it.
>
> Hookbox was presented at PyCon this year, and although hookbox.org seems
> to be having an issue the github page shows activity from March of this
> year, and has active forks, including this 
> one:https://github.com/raikage/hookbox

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django AJAX polling: Best practice?

2011-07-02 Thread Shawn Milochik

On 07/01/2011 05:05 PM, Andreas Pfrengle wrote:

Thanks so far for showing me that I was on the completely wrong
track ;-)

I found that there is really not much official information available
about Hookbox:. That doesn't make an easy
decision for Hookbox.

Has anyone experience with socket.io and gevent instead? Looks
interesting at first glance:





There are other options, such as Orbited, and another on I can't 
remember the name of but I think 'gorilla' had something to do with it.


Hookbox was presented at PyCon this year, and although hookbox.org seems 
to be having an issue the github page shows activity from March of this 
year, and has active forks, including this one:

https://github.com/raikage/hookbox


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django AJAX polling: Best practice?

2011-07-01 Thread Andreas Pfrengle
Thanks so far for showing me that I was on the completely wrong
track ;-)

I found that there is really not much official information available
about Hookbox: . That doesn't make an easy
decision for Hookbox.

Has anyone experience with socket.io and gevent instead? Looks
interesting at first glance:



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django AJAX polling: Best practice?

2011-07-01 Thread Duane Griffin
On 30 June 2011 21:31, Shawn Milochik  wrote:
> This isn't a job for AJAX -- it's a job for Comet, which is tailor-made for
> your exact needs.

Yes. Have your clients subscribe to an update channel for the game
(you will probably need separate channels for each user, unless all
players have full information). Generate the delta when the update
happens and push it out to the relevant channel(s).

> Check out Hookbox. Here's a tutorial which can definitely get you started. I
> was able to learn enough from it to get a small sample working.
> http://charlesleifer.com/blog/writing-a-real-time-chat-app-using-hookbox-and-flask/

Hookbox is a great way to easily get something up and running with
Comet*, but be aware that the project looks sadly unloved at the
moment. I'd be pretty wary about using it in production. On the other
hand, it can't possibly be worse than polling.

Cheers,
Duane.

* shameless plug: especially if you use django-hookbox.

-- 
"I never could learn to drink that blood and call it wine" - Bob Dylan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django AJAX polling: Best practice?

2011-06-30 Thread bruno desthuilliers
On Jun 30, 10:14 pm, Andreas Pfrengle  wrote:
>
> - The other possibility would be a global dict (or instance of an own
> class), let's call it GAMES_ACTIVE

This will break as soon as you have more than one server process.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django AJAX polling: Best practice?

2011-06-30 Thread Shawn Milochik
This isn't a job for AJAX -- it's a job for Comet, which is tailor-made 
for your exact needs.


Check out Hookbox. Here's a tutorial which can definitely get you 
started. I was able to learn enough from it to get a small sample working.

http://charlesleifer.com/blog/writing-a-real-time-chat-app-using-hookbox-and-flask/

Shawn


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django AJAX polling: Best practice?

2011-06-30 Thread Andreas Pfrengle
Hello everyone,

We have a game-application where several players should interact in
realtime (i.e. change attributes of a "game"-object, which is a django
model instance). To my knowledge, best / easiest method for this
problem would be AJAX-polling several times per second, to check
whether the game has changed or not since the last poll. To avoid
waste of bandwidth, we want of course only send the data that has
changed since the last poll, not the whole object over and over again.
We decided to use dajaxice and jquery.

However, I'm not really sure how to approach that task:
- One possiblity would be using the db, writing every change in there
and querying it for every poll. Maybe that game-instance will then get
cached if we use cache-middleware, but since I've never worked with
caching I'm not sure about this and don't feel confident with this
approach.
- The other possibility would be a global dict (or instance of an own
class), let's call it GAMES_ACTIVE, where each active game is stored
by its id. Then I could save the 'state' and the 'changes' of the game
there. So if player X changes game attributes that others would need
to poll, I could update the state and additionally append the new data
to a list of changes for each player that yet wasn't polled:
   GAMES_ACTIVE[game.id]['state'] = game-instance, always up to date
   GAMES_ACTIVE[game.id]['changes'][player_Y] = [list of not yet
polled changes for player Y]
As soon as Player Y polls the changes, they are sent to the client,
and the 'changes' for player Y is reset to an empty list []

Is this a good way to solve the problem? Any other suggestions?

Regards,
Andreas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.