nextcloud/lib/public/IEventSource.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
949 B
PHP
Raw Permalink Normal View History

2014-08-29 11:19:38 -04:00
<?php
declare(strict_types=1);
2014-08-29 11:19:38 -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;
/**
* Wrapper for Server-Sent Events (SSE).
2014-08-29 11:19:38 -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
*
* The connection is opened lazily when the first event is sent.
*
* @see https://developer.mozilla.org/docs/Web/API/Server-sent_events
* @since 8.0.0
2014-08-29 11:19:38 -04:00
*/
interface IEventSource {
/**
* Sends an event to the client.
2014-08-29 11:19:38 -04:00
*
* @param string $type Event type/name.
* @param mixed $data Event payload.
2014-08-29 11:19:38 -04:00
*
* If only one argument is provided, it is sent as a typeless payload (legacy behavior).
* @since 8.0.0
2014-08-29 11:19:38 -04:00
*/
public function send(string $type, mixed $data = null): void;
2014-08-29 11:19:38 -04:00
/**
* Closes the SSE connection.
*
* @since 8.0.0
2014-08-29 11:19:38 -04:00
*/
public function close(): void;
2014-08-29 11:19:38 -04:00
}