Issues (192)

src/Contracts/ChannelManager.php (15 issues)

1
<?php
2
3
namespace BeyondCode\LaravelWebSockets\Contracts;
4
5
use Ratchet\ConnectionInterface;
6
use React\EventLoop\LoopInterface;
7
use React\Promise\PromiseInterface;
8
use stdClass;
9
10
interface ChannelManager
11
{
12
    /**
13
     * Create a new channel manager instance.
14
     *
15
     * @param  LoopInterface  $loop
16
     * @param  string|null  $factoryClass
17
     * @return void
18
     */
19
    public function __construct(LoopInterface $loop, $factoryClass = null);
20
21
    /**
22
     * Find the channel by app & name.
23
     *
24
     * @param  string|int  $appId
25
     * @param  string  $channel
26
     * @return null|BeyondCode\LaravelWebSockets\Channels\Channel
0 ignored issues
show
The type BeyondCode\LaravelWebSoc...ockets\Channels\Channel was not found. Did you mean BeyondCode\LaravelWebSockets\Channels\Channel? If so, make sure to prefix the type with \.
Loading history...
27
     */
28
    public function find($appId, string $channel);
29
30
    /**
31
     * Find a channel by app & name or create one.
32
     *
33
     * @param  string|int  $appId
34
     * @param  string  $channel
35
     * @return BeyondCode\LaravelWebSockets\Channels\Channel
36
     */
37
    public function findOrCreate($appId, string $channel);
38
39
    /**
40
     * Get the local connections, regardless of the channel
41
     * they are connected to.
42
     *
43
     * @return \React\Promise\PromiseInterface
44
     */
45
    public function getLocalConnections(): PromiseInterface;
46
47
    /**
48
     * Get all channels for a specific app
49
     * for the current instance.
50
     *
51
     * @param  string|int  $appId
52
     * @return \React\Promise\PromiseInterface[array]
0 ignored issues
show
Documentation Bug introduced by
The doc comment \React\Promise\PromiseInterface[array] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
53
     */
54
    public function getLocalChannels($appId): PromiseInterface;
55
56
    /**
57
     * Get all channels for a specific app
58
     * across multiple servers.
59
     *
60
     * @param  string|int  $appId
61
     * @return \React\Promise\PromiseInterface[array]
0 ignored issues
show
Documentation Bug introduced by
The doc comment \React\Promise\PromiseInterface[array] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
62
     */
63
    public function getGlobalChannels($appId): PromiseInterface;
64
65
    /**
66
     * Remove connection from all channels.
67
     *
68
     * @param  \Ratchet\ConnectionInterface  $connection
69
     * @return PromiseInterface[bool]
0 ignored issues
show
Documentation Bug introduced by
The doc comment PromiseInterface[bool] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
70
     */
71
    public function unsubscribeFromAllChannels(ConnectionInterface $connection): PromiseInterface;
72
73
    /**
74
     * Subscribe the connection to a specific channel.
75
     *
76
     * @param  \Ratchet\ConnectionInterface  $connection
77
     * @param  string  $channelName
78
     * @param  stdClass  $payload
79
     * @return PromiseInterface[bool]
0 ignored issues
show
Documentation Bug introduced by
The doc comment PromiseInterface[bool] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
80
     */
81
    public function subscribeToChannel(ConnectionInterface $connection, string $channelName, stdClass $payload): PromiseInterface;
82
83
    /**
84
     * Unsubscribe the connection from the channel.
85
     *
86
     * @param  \Ratchet\ConnectionInterface  $connection
87
     * @param  string  $channelName
88
     * @param  stdClass  $payload
89
     * @return PromiseInterface[bool]
0 ignored issues
show
Documentation Bug introduced by
The doc comment PromiseInterface[bool] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
90
     */
91
    public function unsubscribeFromChannel(ConnectionInterface $connection, string $channelName, stdClass $payload): PromiseInterface;
92
93
    /**
94
     * Subscribe the connection to a specific channel, returning
95
     * a promise containing the amount of connections.
96
     *
97
     * @param  string|int  $appId
98
     * @return PromiseInterface[int]
0 ignored issues
show
Documentation Bug introduced by
The doc comment PromiseInterface[int] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
99
     */
100
    public function subscribeToApp($appId): PromiseInterface;
101
102
    /**
103
     * Unsubscribe the connection from the channel, returning
104
     * a promise containing the amount of connections after decrement.
105
     *
106
     * @param  string|int  $appId
107
     * @return PromiseInterface[int]
0 ignored issues
show
Documentation Bug introduced by
The doc comment PromiseInterface[int] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
108
     */
109
    public function unsubscribeFromApp($appId): PromiseInterface;
110
111
    /**
112
     * Get the connections count on the app
113
     * for the current server instance.
114
     *
115
     * @param  string|int  $appId
116
     * @param  string|null  $channelName
117
     * @return PromiseInterface[int]
0 ignored issues
show
Documentation Bug introduced by
The doc comment PromiseInterface[int] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
118
     */
119
    public function getLocalConnectionsCount($appId, string $channelName = null): PromiseInterface;
120
121
    /**
122
     * Get the connections count
123
     * across multiple servers.
124
     *
125
     * @param  string|int  $appId
126
     * @param  string|null  $channelName
127
     * @return PromiseInterface[int]
0 ignored issues
show
Documentation Bug introduced by
The doc comment PromiseInterface[int] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
128
     */
129
    public function getGlobalConnectionsCount($appId, string $channelName = null): PromiseInterface;
130
131
    /**
132
     * Broadcast the message across multiple servers.
133
     *
134
     * @param  string|int  $appId
135
     * @param  string|null  $socketId
136
     * @param  string  $channel
137
     * @param  stdClass  $payload
138
     * @param  string|null  $serverId
139
     * @return PromiseInterface[bool]
0 ignored issues
show
Documentation Bug introduced by
The doc comment PromiseInterface[bool] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
140
     */
141
    public function broadcastAcrossServers($appId, ?string $socketId, string $channel, stdClass $payload, string $serverId = null): PromiseInterface;
142
143
    /**
144
     * Handle the user when it joined a presence channel.
145
     *
146
     * @param  \Ratchet\ConnectionInterface  $connection
147
     * @param  stdClass  $user
148
     * @param  string  $channel
149
     * @param  stdClass  $payload
150
     * @return PromiseInterface[bool]
0 ignored issues
show
Documentation Bug introduced by
The doc comment PromiseInterface[bool] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
151
     */
152
    public function userJoinedPresenceChannel(ConnectionInterface $connection, stdClass $user, string $channel, stdClass $payload): PromiseInterface;
153
154
    /**
155
     * Handle the user when it left a presence channel.
156
     *
157
     * @param  \Ratchet\ConnectionInterface  $connection
158
     * @param  stdClass  $user
159
     * @param  string  $channel
160
     * @param  stdClass  $payload
161
     * @return PromiseInterface[bool]
0 ignored issues
show
Documentation Bug introduced by
The doc comment PromiseInterface[bool] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
162
     */
163
    public function userLeftPresenceChannel(ConnectionInterface $connection, stdClass $user, string $channel): PromiseInterface;
164
165
    /**
166
     * Get the presence channel members.
167
     *
168
     * @param  string|int  $appId
169
     * @param  string  $channel
170
     * @return \React\Promise\PromiseInterface
171
     */
172
    public function getChannelMembers($appId, string $channel): PromiseInterface;
173
174
    /**
175
     * Get a member from a presence channel based on connection.
176
     *
177
     * @param  \Ratchet\ConnectionInterface  $connection
178
     * @param  string  $channel
179
     * @return \React\Promise\PromiseInterface
180
     */
181
    public function getChannelMember(ConnectionInterface $connection, string $channel): PromiseInterface;
182
183
    /**
184
     * Get the presence channels total members count.
185
     *
186
     * @param  string|int  $appId
187
     * @param  array  $channelNames
188
     * @return \React\Promise\PromiseInterface
189
     */
190
    public function getChannelsMembersCount($appId, array $channelNames): PromiseInterface;
191
192
    /**
193
     * Get the socket IDs for a presence channel member.
194
     *
195
     * @param  string|int  $userId
196
     * @param  string|int  $appId
197
     * @param  string  $channelName
198
     * @return \React\Promise\PromiseInterface
199
     */
200
    public function getMemberSockets($userId, $appId, $channelName): PromiseInterface;
201
202
    /**
203
     * Keep tracking the connections availability when they pong.
204
     *
205
     * @param  \Ratchet\ConnectionInterface  $connection
206
     * @return PromiseInterface[bool]
0 ignored issues
show
Documentation Bug introduced by
The doc comment PromiseInterface[bool] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
207
     */
208
    public function connectionPonged(ConnectionInterface $connection): PromiseInterface;
209
210
    /**
211
     * Remove the obsolete connections that didn't ponged in a while.
212
     *
213
     * @return PromiseInterface[bool]
0 ignored issues
show
Documentation Bug introduced by
The doc comment PromiseInterface[bool] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
214
     */
215
    public function removeObsoleteConnections(): PromiseInterface;
216
}
217