provide server side close option for EventStream

This commit is contained in:
Robin Appelman 2012-01-30 23:19:43 +01:00
parent e0f655fb70
commit 6a1121ab2e
2 changed files with 13 additions and 1 deletions

View File

@ -44,8 +44,13 @@ OC.EventSource=function(src){
$('body').append(this.iframe); $('body').append(this.iframe);
this.useFallBack=true; this.useFallBack=true;
OC.EventSource.iframeCount++ OC.EventSource.iframeCount++
} }
//add close listener
this.listen('__internal__',function(data){
if(data=='close'){
this.close();
}
}.bind(this));
} }
OC.EventSource.fallBackSources=[]; OC.EventSource.fallBackSources=[];
OC.EventSource.iframeCount=0;//number of fallback iframes OC.EventSource.iframeCount=0;//number of fallback iframes

View File

@ -70,4 +70,11 @@ class OC_EventSource{
echo PHP_EOL; echo PHP_EOL;
flush(); flush();
} }
/**
* close the connection of the even source
*/
public function close(){
$this->send('__internal__','close');//server side closing can be an issue, let the client do it
}
} }