Question

My server is running on google app engine, my client is a chrome app using angular framework. I'm trying to implement Channel Java API service of GAE. My problem is when channel.open() was called angular show this error at the console: 'beforeunload is not available in packaged apps.' Below is my code, written in controller:

var channel = new goog.appengine.Channel(token);
console.log("channel");
var socket = channel.open();
console.log("socket");
socket.onopen = function(){
    console.log(open);
};

console.log("on open");
socket.onmessage = function(msg){
    console.log("Message: "+msg);
}

(Console show "channel" but not "socket")

Was it helpful?

Solution

  • Create an AngularJS service to hold the list of the chats. This is not required but it is the recommended way to share an observable array (which means with two-way data binding) between controllers.
  • Initiate the Channel API inside that service. Now there's the trick : for the modifications to the observable array to be pushed to the controllers, we need to use the $rootScope method.

Ref - app-engine-channel-api-and-angularjs

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top