fix potential problem when using multiply eventsource's

This commit is contained in:
Robin Appelman 2012-03-31 16:10:29 +02:00
parent 71b70bb05f
commit ad495a9218

View file

@ -33,16 +33,20 @@
*/
OC.EventSource=function(src,data){
var dataStr='';
this.typelessListeners=[];
this.listeners={};
if(data){
for(name in data){
dataStr+=name+'='+encodeURIComponent(data[name])+'&';
}
}
if(!this.useFallBack && typeof EventSource !='undefined'){
this.source=new EventSource(src+'?'+dataStr);
this.source.onmessage=function(e){
for(var i=0;i<this.typelessListeners.length;i++){
this.typelessListeners[i](JSON.parse(e.data));
}
}
}.bind(this);
}else{
iframeId='oc_eventsource_iframe_'+OC.EventSource.iframeCount;
OC.EventSource.fallBackSources[OC.EventSource.iframeCount]=this;