I'm trying to open a channel by copying and pasting a token into an input box, however the console returns,
Invalid+token.
Here is the code for localhost:8080/
<html>
<head>
<script type="text/javascript" src="https://talkgadget.google.com/talkgadget/channel.js"></script>
<script>
function OpenChannel(){
channel = new goog.appengine.Channel(document.getElementById('Token').value);
socket = channel.open();
socket.onmessage = function(message){
console.log(message);
}
socket.onopen = function(){
connected = true;
console.log('opened');
}
socket.onerror = function(err){
console.log(err.description);
}
socket.onclose = function(){
console.log('closed');
}
}
</script>
</head>
<body>
Token: <input id="Token"></input><br/>
<button onclick="OpenChannel()">Open Channel</button>
</body>
</html>
I'm creating the token by opening, "localhost:8080/token?name=...", which writes the channel token to the page. Here is the python class for that page:
class TokenPage(webapp2.RequestHandler):
def get(self):
token = channel.create_channel(self.request.get('name'))
self.response.write(token)
I've pretty much copied the documentation line for line, so I have no idea whats going wrong.
Solution:
replace
<script type="text/javascript" src="https://talkgadget.google.com/talkgadget/channel.js"></script>
with
<script type="text/javascript" src="/_ah/channel/jsapi"></script>
.
Have you tried: