1 | <?php |
||
11 | class FakeReplication implements ReplicationInterface |
||
12 | { |
||
13 | protected $channels = []; |
||
14 | |||
15 | /** |
||
16 | * Boot the pub/sub provider (open connections, initial subscriptions, etc). |
||
17 | * |
||
18 | * @param LoopInterface $loop |
||
19 | * @return self |
||
20 | */ |
||
21 | public function boot(LoopInterface $loop) : ReplicationInterface |
||
25 | |||
26 | /** |
||
27 | * Publish a payload on a specific channel, for a specific app. |
||
28 | * |
||
29 | * @param string $appId |
||
30 | * @param string $channel |
||
31 | * @param stdClass $payload |
||
32 | * @return bool |
||
33 | */ |
||
34 | public function publish(string $appId, string $channel, stdClass $payload) : bool |
||
38 | |||
39 | /** |
||
40 | * Subscribe to receive messages for a channel. |
||
41 | * |
||
42 | * @param string $appId |
||
43 | * @param string $channel |
||
44 | * @return bool |
||
45 | */ |
||
46 | public function subscribe(string $appId, string $channel) : bool |
||
50 | |||
51 | /** |
||
52 | * Unsubscribe from a channel. |
||
53 | * |
||
54 | * @param string $appId |
||
55 | * @param string $channel |
||
56 | * @return bool |
||
57 | */ |
||
58 | public function unsubscribe(string $appId, string $channel) : bool |
||
62 | |||
63 | /** |
||
64 | * Add a member to a channel. To be called when they have |
||
65 | * subscribed to the channel. |
||
66 | * |
||
67 | * @param string $appId |
||
68 | * @param string $channel |
||
69 | * @param string $socketId |
||
70 | * @param string $data |
||
71 | */ |
||
72 | public function joinChannel(string $appId, string $channel, string $socketId, string $data) |
||
76 | |||
77 | /** |
||
78 | * Remove a member from the channel. To be called when they have |
||
79 | * unsubscribed from the channel. |
||
80 | * |
||
81 | * @param string $appId |
||
82 | * @param string $channel |
||
83 | * @param string $socketId |
||
84 | */ |
||
85 | public function leaveChannel(string $appId, string $channel, string $socketId) |
||
92 | |||
93 | /** |
||
94 | * Retrieve the full information about the members in a presence channel. |
||
95 | * |
||
96 | * @param string $appId |
||
97 | * @param string $channel |
||
98 | * @return PromiseInterface |
||
99 | */ |
||
100 | public function channelMembers(string $appId, string $channel) : PromiseInterface |
||
108 | |||
109 | /** |
||
110 | * Get the amount of users subscribed for each presence channel. |
||
111 | * |
||
112 | * @param string $appId |
||
113 | * @param array $channelNames |
||
114 | * @return PromiseInterface |
||
115 | */ |
||
116 | public function channelMemberCounts(string $appId, array $channelNames) : PromiseInterface |
||
126 | } |
||
127 |