I would like to use the GAE Channel API (Python 2.7) with my GWT app (using GWT-GAE-Channel), and I am having trouble figuring out how to get the token created on the server side Python into my GWT app ("index.html" in this example) so that the client side GWT can open the channel. My server-side code currently looks like this:
import webapp2
import jinja2
import os
import uuid
from google.appengine.ext import db
from google.appengine.api import users
from google.appengine.api import channel
jinja_environment = jinja2.Environment(
loader=jinja2.FileSystemLoader(os.path.dirname(__file__)))
class MainPage(webapp2.RequestHandler):
#The main page returns the GWT application
def get(self):
#Create a token when the GWT app is loaded to create a channel to return data
client_id = uuid.uuid4().hex
token = channel.create_channel(client_id, duration_minutes=None)
context = {} #There are currently no template variables in the GWT app
template = jinja_environment.get_template('index.html')
self.response.out.write(template.render(**context))
class A_handler(webapp2.RequestHandler):
def post(self):
client_id = self.request.get('id')
channel.send_message(client_id, message)
app = webapp2.WSGIApplication([('/', MainPage),
('/A', A_handler)],
debug=True)
I have the same example GWT-GAE-Channel client code as this question; however, what is the GWT code to receive "token" from the server for the GWT ChannelFactory.createChannel function? Can the python server send this token to the GWT html in the GET request as a template variable, or would this need to be sent by RPC or some other method?