I'm having an strange behaviour using grails event-push plugin with IE8. I'm using grails 2.2, event-push 1.0M7 and also AngularJS (but this shouldn't be the problem).
I have defined the event in MyEvents.groovy in conf dir
events = {
'newActivity' browser:true
}
Here is the method of a service that sends the events to the browser
@Listener(namespace='browser')
public void sendEvents(UserLevel level, Map<String,List<UserAchievement>> achievements, Map<String,List<UserMission>> missions){
def activities = []
if (level)
activities << new RecentActivity(level)
achievements["user"]?.each{activities << new RecentActivity(it)}
achievements["team"]?.each{ activities << new RecentActivity(it)}
missions["user"]?.each{activities << new RecentActivity(it)}
missions["team"]?.each{activities << new RecentActivity(it)}
if (activities && activities.size()>0)
event(topic:"newActivity",data:activities)
}
And here the js event listener
grailsEvents.on("newActivity",function(data){
for (var i=0;i<data.length;i++){//Add
changeUserImage(data[i]);
$scope.$apply(function(){$scope.activities.unshift(data[i]);});
}
while ($scope.activities.length>$scope.maxElements){ //remove
$scope.$apply(function(){$scope.activities.pop();});
}
});
Edit: These are the grailsEvents inicializations I've tried all with the same result:
window.grailsEvents = new grails.Events($jostalan.urls.base);
window.grailsEvents = new grails.Events($jostalan.urls.base, {transport:"websocket"});
window.grailsEvents = new grails.Events($jostalan.urls.base, {transport:"websocket",shared:true});
I know that sometimes the event is called twice and other none because I've tried putting a console.log, but I've deleted it just to prevent problems with IE8. Also, in Chrome and Firefox everything works as expected, just one call to the method when expected.
The only thing that I've seen that sounds strange for me (as I don't really understand what it means), it's that sometimes I see in grails console the following trace:
grails> cpr.AtmosphereFramework If you have more than one Connector enabled, make sure they both use the same protocol, e.g NIO/APR or HTTP for all. If not, org.atmosphere.container.BlockingIOCometSupport will be used and cannot be changed.
Anyone knows why this strange behaviour is happening and how to solve it?
Edit: I've also tested it with plain javascript and the same strange behaviour happens. Sometimes the event is called, sometimes not and sometime twice
Edit: I've also tried deleting the @Listener annotation from service method as I understand that's not necessary.