websockets.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <?php
  2. return [
  3. /*
  4. |--------------------------------------------------------------------------
  5. | Dashboard Settings
  6. |--------------------------------------------------------------------------
  7. |
  8. | You can configure the dashboard settings from here.
  9. |
  10. */
  11. 'dashboard' => [
  12. 'port' => env('LARAVEL_WEBSOCKETS_PORT', 6001),
  13. 'domain' => env('LARAVEL_WEBSOCKETS_DOMAIN'),
  14. 'path' => env('LARAVEL_WEBSOCKETS_PATH', 'laravel-websockets'),
  15. 'middleware' => [
  16. 'web',
  17. \BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize::class,
  18. ],
  19. ],
  20. 'managers' => [
  21. /*
  22. |--------------------------------------------------------------------------
  23. | Application Manager
  24. |--------------------------------------------------------------------------
  25. |
  26. | An Application manager determines how your websocket server allows
  27. | the use of the TCP protocol based on, for example, a list of allowed
  28. | applications.
  29. | By default, it uses the defined array in the config file, but you can
  30. | anytime implement the same interface as the class and add your own
  31. | custom method to retrieve the apps.
  32. |
  33. */
  34. 'app' => \BeyondCode\LaravelWebSockets\Apps\ConfigAppManager::class,
  35. ],
  36. /*
  37. |--------------------------------------------------------------------------
  38. | Applications Repository
  39. |--------------------------------------------------------------------------
  40. |
  41. | By default, the only allowed app is the one you define with
  42. | your PUSHER_* variables from .env.
  43. | You can configure to use multiple apps if you need to, or use
  44. | a custom App Manager that will handle the apps from a database, per se.
  45. |
  46. | You can apply multiple settings, like the maximum capacity, enable
  47. | client-to-client messages or statistics.
  48. |
  49. */
  50. 'apps' => [
  51. [
  52. 'id' => env('PUSHER_APP_ID'),
  53. 'name' => env('APP_NAME'),
  54. 'host' => env('PUSHER_APP_HOST'),
  55. 'key' => env('PUSHER_APP_KEY'),
  56. 'secret' => env('PUSHER_APP_SECRET'),
  57. 'path' => env('PUSHER_APP_PATH'),
  58. 'capacity' => null,
  59. 'enable_client_messages' => false,
  60. 'enable_statistics' => false,
  61. 'allowed_origins' => [
  62. // env('LARAVEL_WEBSOCKETS_DOMAIN'),
  63. ],
  64. ],
  65. ],
  66. /*
  67. |--------------------------------------------------------------------------
  68. | Broadcasting Replication PubSub
  69. |--------------------------------------------------------------------------
  70. |
  71. | You can enable replication to publish and subscribe to
  72. | messages across the driver.
  73. |
  74. | By default, it is set to 'local', but you can configure it to use drivers
  75. | like Redis to ensure connection between multiple instances of
  76. | WebSocket servers. Just set the driver to 'redis' to enable the PubSub using Redis.
  77. |
  78. */
  79. 'replication' => [
  80. 'mode' => env('WEBSOCKETS_REPLICATION_MODE', 'local'),
  81. 'modes' => [
  82. /*
  83. |--------------------------------------------------------------------------
  84. | Local Replication
  85. |--------------------------------------------------------------------------
  86. |
  87. | Local replication is actually a null replicator, meaning that it
  88. | is the default behaviour of storing the connections into an array.
  89. |
  90. */
  91. 'local' => [
  92. /*
  93. |--------------------------------------------------------------------------
  94. | Channel Manager
  95. |--------------------------------------------------------------------------
  96. |
  97. | The channel manager is responsible for storing, tracking and retrieving
  98. | the channels as long as their members and connections.
  99. |
  100. */
  101. 'channel_manager' => \BeyondCode\LaravelWebSockets\ChannelManagers\LocalChannelManager::class,
  102. /*
  103. |--------------------------------------------------------------------------
  104. | Statistics Collector
  105. |--------------------------------------------------------------------------
  106. |
  107. | The Statistics Collector will, by default, handle the incoming statistics,
  108. | storing them until they will become dumped into another database, usually
  109. | a MySQL database or a time-series database.
  110. |
  111. */
  112. 'collector' => \BeyondCode\LaravelWebSockets\Statistics\Collectors\MemoryCollector::class,
  113. ],
  114. 'redis' => [
  115. 'connection' => env('WEBSOCKETS_REDIS_REPLICATION_CONNECTION', 'default'),
  116. /*
  117. |--------------------------------------------------------------------------
  118. | Channel Manager
  119. |--------------------------------------------------------------------------
  120. |
  121. | The channel manager is responsible for storing, tracking and retrieving
  122. | the channels as long as their members and connections.
  123. |
  124. */
  125. 'channel_manager' => \BeyondCode\LaravelWebSockets\ChannelManagers\RedisChannelManager::class,
  126. /*
  127. |--------------------------------------------------------------------------
  128. | Statistics Collector
  129. |--------------------------------------------------------------------------
  130. |
  131. | The Statistics Collector will, by default, handle the incoming statistics,
  132. | storing them until they will become dumped into another database, usually
  133. | a MySQL database or a time-series database.
  134. |
  135. */
  136. 'collector' => \BeyondCode\LaravelWebSockets\Statistics\Collectors\RedisCollector::class,
  137. ],
  138. ],
  139. ],
  140. 'statistics' => [
  141. /*
  142. |--------------------------------------------------------------------------
  143. | Statistics Store
  144. |--------------------------------------------------------------------------
  145. |
  146. | The Statistics Store is the place where all the temporary stats will
  147. | be dumped. This is a much reliable store and will be used to display
  148. | graphs or handle it later on your app.
  149. |
  150. */
  151. 'store' => \BeyondCode\LaravelWebSockets\Statistics\Stores\DatabaseStore::class,
  152. /*
  153. |--------------------------------------------------------------------------
  154. | Statistics Interval Period
  155. |--------------------------------------------------------------------------
  156. |
  157. | Here you can specify the interval in seconds at which
  158. | statistics should be logged.
  159. |
  160. */
  161. 'interval_in_seconds' => 60,
  162. /*
  163. |--------------------------------------------------------------------------
  164. | Statistics Deletion Period
  165. |--------------------------------------------------------------------------
  166. |
  167. | When the clean-command is executed, all recorded statistics older than
  168. | the number of days specified here will be deleted.
  169. |
  170. */
  171. 'delete_statistics_older_than_days' => 60,
  172. ],
  173. /*
  174. |--------------------------------------------------------------------------
  175. | Maximum Request Size
  176. |--------------------------------------------------------------------------
  177. |
  178. | The maximum request size in kilobytes that is allowed for
  179. | an incoming WebSocket request.
  180. |
  181. */
  182. 'max_request_size_in_kb' => 250,
  183. /*
  184. |--------------------------------------------------------------------------
  185. | SSL Configuration
  186. |--------------------------------------------------------------------------
  187. |
  188. | By default, the configuration allows only on HTTP. For SSL, you need
  189. | to set up the the certificate, the key, and optionally, the passphrase
  190. | for the private key.
  191. | You will need to restart the server for the settings to take place.
  192. |
  193. */
  194. 'ssl' => [
  195. 'local_cert' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT', null),
  196. 'capath' => env('LARAVEL_WEBSOCKETS_SSL_CA', null),
  197. 'local_pk' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_PK', null),
  198. 'passphrase' => env('LARAVEL_WEBSOCKETS_SSL_PASSPHRASE', null),
  199. 'verify_peer' => env('APP_ENV') === 'production',
  200. 'allow_self_signed' => env('APP_ENV') !== 'production',
  201. ],
  202. /*
  203. |--------------------------------------------------------------------------
  204. | Route Handlers
  205. |--------------------------------------------------------------------------
  206. |
  207. | Here you can specify the route handlers that will take over
  208. | the incoming/outgoing websocket connections. You can extend the
  209. | original class and implement your own logic, alongside
  210. | with the existing logic.
  211. |
  212. */
  213. 'handlers' => [
  214. 'websocket' => \BeyondCode\LaravelWebSockets\Server\WebSocketHandler::class,
  215. 'health' => \BeyondCode\LaravelWebSockets\Server\HealthHandler::class,
  216. 'trigger_event' => \BeyondCode\LaravelWebSockets\API\TriggerEvent::class,
  217. 'fetch_channels' => \BeyondCode\LaravelWebSockets\API\FetchChannels::class,
  218. 'fetch_channel' => \BeyondCode\LaravelWebSockets\API\FetchChannel::class,
  219. 'fetch_users' => \BeyondCode\LaravelWebSockets\API\FetchUsers::class,
  220. ],
  221. /*
  222. |--------------------------------------------------------------------------
  223. | Promise Resolver
  224. |--------------------------------------------------------------------------
  225. |
  226. | The promise resolver is a class that takes a input value and is
  227. | able to make sure the PHP code runs async by using ->then(). You can
  228. | use your own Promise Resolver. This is usually changed when you want to
  229. | intercept values by the promises throughout the app, like in testing
  230. | to switch from async to sync.
  231. |
  232. */
  233. 'promise_resolver' => \React\Promise\FulfilledPromise::class,
  234. ];