Hi there,

(First I'm french... so please apologize for my english mistakes)

I'm working with GAE, using python, and get the same problem as you, to 
refresh tokens for users allready connected

just to say... I've started a chat-script, by using a login script, with 
session in python:

from gaesessions import get_current_session


& for example, calling the session using :

def Guestbook(message, tokens=None):
>     if not tokens:
>         tokens = memcache.get('tokens')
>     if tokens:
>         session = get_current_session()
>         user=session.get('user_name')


But each time I restarted the server, the user wasn't automatically 
reconnected... which is quite the same problem as yours 

here is my issue, from client-side :

<!DOCTYPE html>
> <html>
> <head>
> <meta charset="utf-8"/>
> <title>GAE Test-Channel-API</title>
> <style type="text/css">
> #userlist {
> margin: 5px 0 0 0;
> padding: 5px;
> border: 1px solid #ccc;
> height: 320px;
> overflow: auto;
> font-size:12px;
> }
> </style>
> <script src="/_ah/channel/jsapi"></script>
> <script src="/jquery.js"></script>
> <script>
> reco_count=0;
> $(document).ready(
> function() {
> var token;
> function get_token() {
> if (token) {return false;} ;// try to prevent duplicate entry 
> $.get('/get_token', function(data){
> if (data) {
> reco_count=0;
> token = data;
> document.getElementById('userlist').innerHTML=token + " connected!<br>"
> openChannel();
> }
> else
> {
> document.getElementById('userlist').innerHTML=document.getElementById('userlist').innerHTML+"Can't
>  
> connect... Channel Full ? !<br>";
> }
> });
> setTimeout(function() {if (!token) {Reconnect();} },4000 ); // retry to 
> connect
> }
> get_token();
>
> function Reconnect() {
> setTimeout(function() {if (token) {reco_count=0; return false;} else 
> {reco_count=reco_count+1; 
> document.getElementById('userlist').innerHTML="Server error !<br>Trying to 
> reconnect ("+reco_count+")... fail <br>";  get_token(); }; }, 4000);
> }
> function onClose() {
> token=null;
> Reconnect();
> }
> function onError() {
> token=null;
> Reconnect();
> }
> function onOpen() {
> $.post('/open', {'token': token});
> }
> function onMessage(m) {
> // getting message
> // TODO
> }
> function openChannel() {
> var channel = new goog.appengine.Channel(token);
> var handler = {
> 'onopen': onOpen,
> 'onmessage': onMessage,
> 'onerror': onError,
> 'onclose': onClose 
> };
> channel.open(handler);
> }
> $(window).bind('beforeunload', function() {
> if (token) {
> document.getElementById('userlist').innerHTML=document.getElementById('userlist').innerHTML+token
>  
> + " disconnected!<br>"
> $.post('/del_token', {'token': token});
> }
> })
> }
> )
> </script>
> </head>
> <body>
> <div id="userlist" style="position:relative;top:0px;left:0px;"></div>
> </body></html>


Hoping it will help some,

Rgds,

guibs





-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine-java/-/cqdUw6HMleYJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to