views:

55

answers:

2

Every example for GAE Chats uses some kind of polling. However, if my GAE app holds a list of clients (in the datastore if necessary), perhaps I could avoid polling by sending a message to all these clients. How can I achieve this?

+2  A: 

You've probably seen some chat room examples...

Since you just want to send a message to users on your datastore (Tip: the IMProperty is great to store such data), it's just a matter of directly sending the message:

from google.appengine.api import xmpp
# `destination` is a list of JIDS
# `message` is a normal unicode string
xmpp.send_message(destination, message)

You can find a great tutorial on using XMPP by Nick Johnson here

Caio Romão
so when i integrate the chat into my application i could send messages to the users using xmpp and jids like: whatever@upserip:userport. Then my app sends my message as a http request. correct? can i traverse NAT like that?
Laures
@Laures now you got me confused. From what I understand, what you're looking for is actually on Robert's anwer, not mine. I'll be upvoting his answer.
Caio Romão
ok...now i'm confused. I want to recieve information from clients and distribute recieved data to all clients. i want to do this without polling. when the channel api is out this should be simple, but why is it imposible now? (maybe i should have mentioned that this is my first gae or network related project)
Laures
It is not impossible now. You could potentially use XMPP in combination with some thing like Strophe (http://code.stanziq.com/strophe/) to achieve what you want to. What you are looking for is actually detailed in my response to your question.
Robert Kluin
+5  A: 

If you are talking about HTTP, the short answer is that GAE does not currently support it. What I think you are asking about is sometimes called BOSH. Once WebSockets become more widespread, they will be an excellent solution for this problem.

In the mean time you might want to look at XMPP. Using XMPP you can avoid polling. Google has announced a Channel API (yet to be released) which will basically give you the same features as websockets.

Robert Kluin