1 | <?php |
||
11 | class LocalClient implements ReplicationInterface |
||
12 | { |
||
13 | /** |
||
14 | * Mapping of the presence JSON data for users in each channel. |
||
15 | * |
||
16 | * @var string[][] |
||
17 | */ |
||
18 | protected $channelData = []; |
||
19 | |||
20 | /** |
||
21 | * Boot the pub/sub provider (open connections, initial subscriptions, etc). |
||
22 | * |
||
23 | * @param LoopInterface $loop |
||
24 | * @return self |
||
25 | */ |
||
26 | public function boot(LoopInterface $loop) : ReplicationInterface |
||
30 | |||
31 | /** |
||
32 | * Publish a payload on a specific channel, for a specific app. |
||
33 | * |
||
34 | * @param string $appId |
||
35 | * @param string $channel |
||
36 | * @param stdClass $payload |
||
37 | * @return bool |
||
38 | */ |
||
39 | public function publish(string $appId, string $channel, stdClass $payload) : bool |
||
44 | |||
45 | /** |
||
46 | * Subscribe to receive messages for a channel. |
||
47 | * |
||
48 | * @param string $appId |
||
49 | * @param string $channel |
||
50 | * @return bool |
||
51 | */ |
||
52 | public function subscribe(string $appId, string $channel) : bool |
||
56 | |||
57 | /** |
||
58 | * Unsubscribe from a channel. |
||
59 | * |
||
60 | * @param string $appId |
||
61 | * @param string $channel |
||
62 | * @return bool |
||
63 | */ |
||
64 | public function unsubscribe(string $appId, string $channel) : bool |
||
68 | |||
69 | /** |
||
70 | * Add a member to a channel. To be called when they have |
||
71 | * subscribed to the channel. |
||
72 | * |
||
73 | * @param string $appId |
||
74 | * @param string $channel |
||
75 | * @param string $socketId |
||
76 | * @param string $data |
||
77 | */ |
||
78 | public function joinChannel(string $appId, string $channel, string $socketId, string $data) |
||
82 | |||
83 | /** |
||
84 | * Remove a member from the channel. To be called when they have |
||
85 | * unsubscribed from the channel. |
||
86 | * |
||
87 | * @param string $appId |
||
88 | * @param string $channel |
||
89 | * @param string $socketId |
||
90 | */ |
||
91 | public function leaveChannel(string $appId, string $channel, string $socketId) |
||
98 | |||
99 | /** |
||
100 | * Retrieve the full information about the members in a presence channel. |
||
101 | * |
||
102 | * @param string $appId |
||
103 | * @param string $channel |
||
104 | * @return PromiseInterface |
||
105 | */ |
||
106 | public function channelMembers(string $appId, string $channel) : PromiseInterface |
||
117 | |||
118 | /** |
||
119 | * Get the amount of users subscribed for each presence channel. |
||
120 | * |
||
121 | * @param string $appId |
||
122 | * @param array $channelNames |
||
123 | * @return PromiseInterface |
||
124 | */ |
||
125 | public function channelMemberCounts(string $appId, array $channelNames) : PromiseInterface |
||
138 | } |
||
139 |