This repository has been archived by the owner on Feb 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 637
/
Copy pathwebsockets.php
326 lines (257 loc) · 11 KB
/
websockets.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
<?php
return [
/*
|--------------------------------------------------------------------------
| Dashboard Settings
|--------------------------------------------------------------------------
|
| You can configure the dashboard settings from here.
|
*/
'dashboard' => [
'port' => env('LARAVEL_WEBSOCKETS_PORT', 6001),
'domain' => env('LARAVEL_WEBSOCKETS_DOMAIN'),
'path' => env('LARAVEL_WEBSOCKETS_PATH', 'laravel-websockets'),
'middleware' => [
'web',
\BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize::class,
],
],
'managers' => [
/*
|--------------------------------------------------------------------------
| Application Manager
|--------------------------------------------------------------------------
|
| An Application manager determines how your websocket server allows
| the use of the TCP protocol based on, for example, a list of allowed
| applications.
| By default, it uses the defined array in the config file, but you can
| choose to use SQLite or MySQL application managers, or define a
| custom application manager.
|
*/
'app' => \BeyondCode\LaravelWebSockets\Apps\ConfigAppManager::class,
/*
|--------------------------------------------------------------------------
| SQLite application manager
|--------------------------------------------------------------------------
|
| The SQLite database to use when using the SQLite application manager.
|
*/
'sqlite' => [
'database' => storage_path('laravel-websockets.sqlite'),
],
/*
|--------------------------------------------------------------------------
| MySql application manager
|--------------------------------------------------------------------------
|
| The MySQL database connection to use.
|
*/
'mysql' => [
'connection' => env('DB_CONNECTION', 'mysql'),
'table' => 'websockets_apps',
],
],
/*
|--------------------------------------------------------------------------
| Applications Repository
|--------------------------------------------------------------------------
|
| By default, the only allowed app is the one you define with
| your PUSHER_* variables from .env.
| You can configure to use multiple apps if you need to, or use
| a custom App Manager that will handle the apps from a database, per se.
|
| You can apply multiple settings, like the maximum capacity, enable
| client-to-client messages or statistics.
|
*/
'apps' => [
[
'id' => env('PUSHER_APP_ID'),
'name' => env('APP_NAME'),
'host' => env('PUSHER_APP_HOST'),
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'path' => env('PUSHER_APP_PATH'),
'capacity' => null,
'enable_client_messages' => false,
'enable_statistics' => true,
'allowed_origins' => [
// env('LARAVEL_WEBSOCKETS_DOMAIN'),
],
],
],
/*
|--------------------------------------------------------------------------
| Broadcasting Replication PubSub
|--------------------------------------------------------------------------
|
| You can enable replication to publish and subscribe to
| messages across the driver.
|
| By default, it is set to 'local', but you can configure it to use drivers
| like Redis to ensure connection between multiple instances of
| WebSocket servers. Just set the driver to 'redis' to enable the PubSub using Redis.
|
*/
'replication' => [
'mode' => env('WEBSOCKETS_REPLICATION_MODE', 'local'),
'modes' => [
/*
|--------------------------------------------------------------------------
| Local Replication
|--------------------------------------------------------------------------
|
| Local replication is actually a null replicator, meaning that it
| is the default behaviour of storing the connections into an array.
|
*/
'local' => [
/*
|--------------------------------------------------------------------------
| Channel Manager
|--------------------------------------------------------------------------
|
| The channel manager is responsible for storing, tracking and retrieving
| the channels as long as their members and connections.
|
*/
'channel_manager' => \BeyondCode\LaravelWebSockets\ChannelManagers\LocalChannelManager::class,
/*
|--------------------------------------------------------------------------
| Statistics Collector
|--------------------------------------------------------------------------
|
| The Statistics Collector will, by default, handle the incoming statistics,
| storing them until they will become dumped into another database, usually
| a MySQL database or a time-series database.
|
*/
'collector' => \BeyondCode\LaravelWebSockets\Statistics\Collectors\MemoryCollector::class,
],
'redis' => [
'connection' => env('WEBSOCKETS_REDIS_REPLICATION_CONNECTION', 'default'),
/*
|--------------------------------------------------------------------------
| Channel Manager
|--------------------------------------------------------------------------
|
| The channel manager is responsible for storing, tracking and retrieving
| the channels as long as their members and connections.
|
*/
'channel_manager' => \BeyondCode\LaravelWebSockets\ChannelManagers\RedisChannelManager::class,
/*
|--------------------------------------------------------------------------
| Statistics Collector
|--------------------------------------------------------------------------
|
| The Statistics Collector will, by default, handle the incoming statistics,
| storing them until they will become dumped into another database, usually
| a MySQL database or a time-series database.
|
*/
'collector' => \BeyondCode\LaravelWebSockets\Statistics\Collectors\RedisCollector::class,
],
],
],
'statistics' => [
/*
|--------------------------------------------------------------------------
| Statistics Store
|--------------------------------------------------------------------------
|
| The Statistics Store is the place where all the temporary stats will
| be dumped. This is a much reliable store and will be used to display
| graphs or handle it later on your app.
|
*/
'store' => \BeyondCode\LaravelWebSockets\Statistics\Stores\DatabaseStore::class,
/*
|--------------------------------------------------------------------------
| Statistics Interval Period
|--------------------------------------------------------------------------
|
| Here you can specify the interval in seconds at which
| statistics should be logged.
|
*/
'interval_in_seconds' => 60,
/*
|--------------------------------------------------------------------------
| Statistics Deletion Period
|--------------------------------------------------------------------------
|
| When the clean-command is executed, all recorded statistics older than
| the number of days specified here will be deleted.
|
*/
'delete_statistics_older_than_days' => 60,
],
/*
|--------------------------------------------------------------------------
| Maximum Request Size
|--------------------------------------------------------------------------
|
| The maximum request size in kilobytes that is allowed for
| an incoming WebSocket request.
|
*/
'max_request_size_in_kb' => 250,
/*
|--------------------------------------------------------------------------
| SSL Configuration
|--------------------------------------------------------------------------
|
| By default, the configuration allows only on HTTP. For SSL, you need
| to set up the the certificate, the key, and optionally, the passphrase
| for the private key.
| You will need to restart the server for the settings to take place.
|
*/
'ssl' => [
'local_cert' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT', null),
'capath' => env('LARAVEL_WEBSOCKETS_SSL_CA', null),
'local_pk' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_PK', null),
'passphrase' => env('LARAVEL_WEBSOCKETS_SSL_PASSPHRASE', null),
'verify_peer' => env('APP_ENV') === 'production',
'allow_self_signed' => env('APP_ENV') !== 'production',
],
/*
|--------------------------------------------------------------------------
| Route Handlers
|--------------------------------------------------------------------------
|
| Here you can specify the route handlers that will take over
| the incoming/outgoing websocket connections. You can extend the
| original class and implement your own logic, alongside
| with the existing logic.
|
*/
'handlers' => [
'websocket' => \BeyondCode\LaravelWebSockets\Server\WebSocketHandler::class,
'health' => \BeyondCode\LaravelWebSockets\Server\HealthHandler::class,
'trigger_event' => \BeyondCode\LaravelWebSockets\API\TriggerEvent::class,
'fetch_channels' => \BeyondCode\LaravelWebSockets\API\FetchChannels::class,
'fetch_channel' => \BeyondCode\LaravelWebSockets\API\FetchChannel::class,
'fetch_users' => \BeyondCode\LaravelWebSockets\API\FetchUsers::class,
],
/*
|--------------------------------------------------------------------------
| Promise Resolver
|--------------------------------------------------------------------------
|
| The promise resolver is a class that takes a input value and is
| able to make sure the PHP code runs async by using ->then(). You can
| use your own Promise Resolver. This is usually changed when you want to
| intercept values by the promises throughout the app, like in testing
| to switch from async to sync.
|
*/
'promise_resolver' => \React\Promise\FulfilledPromise::class,
];