0

I am creating a web application using Google App Engine with the Channel API. This is my first attempt at doing anything Ajax-like, and I suspect there is a standard technique for solving my problem, but I've been unable to find it.

My client program will post messages to the server. If the message is not able to be sent, for example, if the channel is closed, what happens to the message? What if the client is on a tablet and the user walks out of the range of the wireless network? For my application, it is critical that the message get resent, but I don't see how to do this.

When the channel is closed, I know I should request a new token from the server, but I don't know how my client can get that token and open the connection without reloading the page (and hence losing the data). In the demo given here, the client needs to know the token.

var channel = new goog.appengine.Channel({{token}});

But I have read elsewhere that the client does not need to know the token. -- How would that work?

Also, the onerror and onclose callback functions do not seem to give me the messages that failed, so how would I know what needs to be resent?

I'd be very grateful if someone could push me in the right direction.

jpl
  • 38
  • 1
  • 1
  • 6

1 Answers1

0

If it's "critical that the message get resent" then you should maybe consider native client instead of browser. If user is out of range and closes or reloads browser window then data will be lost for sure.

  1. "I don't know how my client can get that token and open the connection without reloading the page". Use AJAX to make a call to server - this will not reload the page.

  2. Client needs the token to open a channel. No way around it.

  3. onclose should be called when socket closes. If client loses connection then it can take some time before socket timeouts and onclose gets called.

Peter Knego
  • 78,855
  • 10
  • 118
  • 147