fix potential problem when using multiply eventsource's
This commit is contained in:
parent
71b70bb05f
commit
ad495a9218
1 changed files with 7 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue