-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Endpoint.php
76 lines (66 loc) · 2.51 KB
/
Endpoint.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace Amp\Websocket\Server;
use Amp\Http\Server\ErrorHandler;
use Amp\Promise;
use Amp\Websocket\Client;
use Amp\Websocket\Options;
use Psr\Log\LoggerInterface as PsrLogger;
interface Endpoint
{
/**
* Broadcast a UTF-8 text message to all clients (except those given in the optional array).
*
* @param string $data Data to send.
* @param int[] $exceptIds List of IDs to exclude from the broadcast.
*
* @return Promise<[\Throwable[], int[]]> Resolves once the message has been sent to all clients. Note it is
* generally undesirable to yield this promise in a coroutine.
*/
public function broadcast(string $data, array $exceptIds = []): Promise;
/**
* Send a binary message to all clients (except those given in the optional array).
*
* @param string $data Data to send.
* @param int[] $exceptIds List of IDs to exclude from the broadcast.
*
* @return Promise<[\Throwable[], int[]]> Resolves once the message has been sent to all clients. Note it is
* generally undesirable to yield this promise in a coroutine.
*/
public function broadcastBinary(string $data, array $exceptIds = []): Promise;
/**
* Send a UTF-8 text message to a set of clients.
*
* @param string $data Data to send.
* @param int[] $clientIds Array of client IDs.
*
* @return Promise<[\Throwable[], int[]]> Resolves once the message has been sent to all clients. Note it is
* generally undesirable to yield this promise in a coroutine.
*/
public function multicast(string $data, array $clientIds): Promise;
/**
* Send a binary message to a set of clients.
*
* @param string $data Data to send.
* @param int[] $clientIds Array of client IDs.
*
* @return Promise<[\Throwable[], int[]]> Resolves once the message has been sent to all clients. Note it is
* generally undesirable to yield this promise in a coroutine.
*/
public function multicastBinary(string $data, array $clientIds): Promise;
/**
* @return Client[] Array of Client objects currently connected to this endpoint indexed by their IDs.
*/
public function getClients(): array;
/**
* @return PsrLogger HTTP server logger.
*/
public function getLogger(): PsrLogger;
/**
* @return ErrorHandler HTTP server error handler.
*/
public function getErrorHandler(): ErrorHandler;
/**
* @return Options
*/
public function getOptions(): Options;
}