I want to use the channel api to push updates to open pages, What I have done so far is to store the page client ids in ndb - I have included a code summary
My question is: How do I manage closed pages and expired tokens?
and is this the best way to push updates to many open pages?
open page code:
import webapp2
import uuid
from google.appengine.api import channel
from google.appengine.ext import ndb
class Frame(ndb.Model):
clientID = ndb.StringProperty()
date = ndb.DateTimeProperty(auto_now_add=True)
class MainHandler(BaseHandler):
def get(self):
client_id = str(uuid.uuid4())
channel_token = channel.create_channel(client_id)
frame = Frame(clientID = client_id)
frame.put()
self.render_response('home.html',** "token":channel_token,"client_id":client_id)
send message code:
from google.appengine.api import channel
from google.appengine.ext import ndb
class Frame(ndb.Model):
clientID = ndb.StringProperty()
date = ndb.DateTimeProperty(auto_now_add=True)
frames = Frame.query().fetch(10)
for i in frames:
channel.send_message(i.clientID, "some message to update")