2014-08-29 11:19:38 -04:00
|
|
|
<?php
|
2024-05-23 03:26:56 -04:00
|
|
|
|
2026-03-21 09:36:35 -04:00
|
|
|
declare(strict_types=1);
|
2014-08-29 11:19:38 -04:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2014-08-29 11:19:38 -04:00
|
|
|
*/
|
|
|
|
|
namespace OCP;
|
|
|
|
|
|
|
|
|
|
/**
|
2026-03-21 09:36:35 -04:00
|
|
|
* Wrapper for Server-Sent Events (SSE).
|
2014-08-29 11:19:38 -04:00
|
|
|
*
|
2026-03-21 09:36:35 -04:00
|
|
|
* Use SSE with caution: too many concurrent open requests can overload or stall the server.
|
2014-09-03 19:10:02 -04:00
|
|
|
*
|
2026-03-21 09:36:35 -04:00
|
|
|
* The connection is opened lazily when the first event is sent.
|
|
|
|
|
*
|
|
|
|
|
* @see https://developer.mozilla.org/docs/Web/API/Server-sent_events
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 8.0.0
|
2014-08-29 11:19:38 -04:00
|
|
|
*/
|
|
|
|
|
interface IEventSource {
|
|
|
|
|
/**
|
2026-03-21 09:36:35 -04:00
|
|
|
* Sends an event to the client.
|
2014-08-29 11:19:38 -04:00
|
|
|
*
|
2026-03-21 09:36:35 -04:00
|
|
|
* @param string $type Event type/name.
|
|
|
|
|
* @param mixed $data Event payload.
|
2014-08-29 11:19:38 -04:00
|
|
|
*
|
2026-03-21 09:36:35 -04:00
|
|
|
* If only one argument is provided, it is sent as a typeless payload (legacy behavior).
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 8.0.0
|
2014-08-29 11:19:38 -04:00
|
|
|
*/
|
2026-03-21 09:36:35 -04:00
|
|
|
public function send(string $type, mixed $data = null): void;
|
2014-08-29 11:19:38 -04:00
|
|
|
|
|
|
|
|
/**
|
2026-03-21 09:36:35 -04:00
|
|
|
* Closes the SSE connection.
|
|
|
|
|
*
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 8.0.0
|
2014-08-29 11:19:38 -04:00
|
|
|
*/
|
2026-03-21 09:36:35 -04:00
|
|
|
public function close(): void;
|
2014-08-29 11:19:38 -04:00
|
|
|
}
|