diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-08-29 17:19:38 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-09-03 13:36:15 +0200 |
commit | dad53180bc6c554336c3a30abf64e45c242b2262 (patch) | |
tree | 35cb817c892347db96792d5b13f5d64b9261901e /lib | |
parent | 54c918fe48eeae35adae64381f1e1c41ac4a660b (diff) | |
download | nextcloud-server-dad53180bc6c554336c3a30abf64e45c242b2262.tar.gz nextcloud-server-dad53180bc6c554336c3a30abf64e45c242b2262.zip |
Add event source to the public api
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/eventsource.php | 2 | ||||
-rw-r--r-- | lib/private/server.php | 9 | ||||
-rw-r--r-- | lib/public/ieventsource.php | 32 | ||||
-rw-r--r-- | lib/public/iservercontainer.php | 7 |
4 files changed, 49 insertions, 1 deletions
diff --git a/lib/private/eventsource.php b/lib/private/eventsource.php index 5a870ae3f3a..22782d677e4 100644 --- a/lib/private/eventsource.php +++ b/lib/private/eventsource.php @@ -12,7 +12,7 @@ * * use server side events with caution, to many open requests can hang the server */ -class OC_EventSource { +class OC_EventSource implements \OCP\IEventSource { /** * @var bool */ diff --git a/lib/private/server.php b/lib/private/server.php index 5d40f1327f6..1c3b1b03ce9 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -492,4 +492,13 @@ class Server extends SimpleContainer implements IServerContainer { } return new CertificateManager($user); } + + /** + * Returns a search instance + * + * @return \OCP\IEventSource + */ + function getEventSource() { + return new \OC_EventSource(); + } } diff --git a/lib/public/ieventsource.php b/lib/public/ieventsource.php new file mode 100644 index 00000000000..ea4bfc73d42 --- /dev/null +++ b/lib/public/ieventsource.php @@ -0,0 +1,32 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP; + +/** + * wrapper for server side events (http://en.wikipedia.org/wiki/Server-sent_events) + * includes a fallback for older browsers and IE + * + * use server side events with caution, to many open requests can hang the server + */ +interface IEventSource { + /** + * send a message to the client + * + * @param string $type + * @param mixed $data + * + * if only one parameter is given, a typeless message will be send with that parameter as data + */ + public function send($type, $data = null); + + /** + * close the connection of the event source + */ + public function close(); +} diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php index 60b0b497c54..24d8894d9fe 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -235,4 +235,11 @@ interface IServerContainer { * @return \OCP\ICertificateManager */ function getCertificateManager($user = null); + + /** + * Returns a search instance + * + * @return \OCP\IEventSource + */ + function getEventSource(); } |