GAE API Reconnects

I am working on a chat application on top of GAE and its feed APIs. I studied the document and the examples given, also looked at some of the answers here, but I don’t feel that I have the whole picture of the clientId / Token mechanics.

1). The token is issued within 2 hours, so when it expires, I have to request a new one. I also get a disconnect message from my handler with the client id parameter. Does this mean that the channel is closed at this point, and by requesting a new token, I basically create a new channel? So it doesn't even matter which client ID I can use at this moment, old or brand new? Will GAE also consider this a newly created channel?

2). If the user leaves my page before the token expires (I will get the presence of disconnection). And then it returns (still inside this 2-hour window), can I reconnect it to the same channel with the old token (say, I have them in cookies)? If so, does GAE not consider this a newly created channel?

3). If the answer to the above question is yes, can I remove the garbage to remove the disabled client identifiers and tokens on the server side and distribute them to the new connected clients. In this case, if the user returns to my page, and his old client identifier / token is already used by someone else, he will simply get another pair from the pool. Or is this the place when the one channel per page rule comes into force?

Thank you before you greet and cheers, Alex

+4
source share
1 answer

Answers:

1) Yes, if you reuse an existing customer ID or a new one, you will pay to create a new channel.

2) Yes, you can connect to an existing token, and you will not pay to create a new channel. Running create_channel on the server is the one that is worth it; everything you do on the client is free.

3) You could do it. Keep in mind that if you have multiple clients trying to connect to the same token, you will get unpredictable results.

Hope this helps!

+7
source

Source: https://habr.com/ru/post/1392317/


All Articles