swoole_websocket.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. return [
  3. /*
  4. |--------------------------------------------------------------------------
  5. | Websocket handler for onOpen and onClose callback
  6. | Replace this handler if you want to customize your websocket handler
  7. |--------------------------------------------------------------------------
  8. */
  9. 'handler' => SwooleTW\Http\Websocket\SocketIO\WebsocketHandler::class,
  10. /*
  11. |--------------------------------------------------------------------------
  12. | Default frame parser
  13. | Replace it if you want to customize your websocket payload
  14. |--------------------------------------------------------------------------
  15. */
  16. 'parser' => SwooleTW\Http\Websocket\SocketIO\SocketIOParser::class,
  17. /*
  18. |--------------------------------------------------------------------------
  19. | Websocket route file path
  20. |--------------------------------------------------------------------------
  21. */
  22. 'route_file' => base_path('routes/websocket.php'),
  23. /*
  24. |--------------------------------------------------------------------------
  25. | Default middleware for on connect request
  26. |--------------------------------------------------------------------------
  27. */
  28. 'middleware' => [
  29. // SwooleTW\Http\Websocket\Middleware\DecryptCookies::class,
  30. // SwooleTW\Http\Websocket\Middleware\StartSession::class,
  31. // SwooleTW\Http\Websocket\Middleware\Authenticate::class,
  32. ],
  33. /*
  34. |--------------------------------------------------------------------------
  35. | Websocket handler for customized onHandShake callback
  36. |--------------------------------------------------------------------------
  37. */
  38. 'handshake' => [
  39. 'enabled' => false,
  40. 'handler' => SwooleTW\Http\Websocket\HandShakeHandler::class,
  41. ],
  42. /*
  43. |--------------------------------------------------------------------------
  44. | Default websocket driver
  45. |--------------------------------------------------------------------------
  46. */
  47. 'default' => 'table',
  48. /*
  49. |--------------------------------------------------------------------------
  50. | Websocket client's heartbeat interval (ms)
  51. |--------------------------------------------------------------------------
  52. */
  53. 'ping_interval' => 25000,
  54. /*
  55. |--------------------------------------------------------------------------
  56. | Websocket client's heartbeat interval timeout (ms)
  57. |--------------------------------------------------------------------------
  58. */
  59. 'ping_timeout' => 60000,
  60. /*
  61. |--------------------------------------------------------------------------
  62. | Room drivers mapping
  63. |--------------------------------------------------------------------------
  64. */
  65. 'drivers' => [
  66. 'table' => SwooleTW\Http\Websocket\Rooms\TableRoom::class,
  67. 'redis' => SwooleTW\Http\Websocket\Rooms\RedisRoom::class,
  68. ],
  69. /*
  70. |--------------------------------------------------------------------------
  71. | Room drivers settings
  72. |--------------------------------------------------------------------------
  73. */
  74. 'settings' => [
  75. 'table' => [
  76. 'room_rows' => 4096,
  77. 'room_size' => 2048,
  78. 'client_rows' => 8192,
  79. 'client_size' => 2048,
  80. ],
  81. 'redis' => [
  82. 'server' => [
  83. 'host' => env('REDIS_HOST', '127.0.0.1'),
  84. 'password' => env('REDIS_PASSWORD', null),
  85. 'port' => env('REDIS_PORT', 6379),
  86. 'database' => 0,
  87. 'persistent' => true,
  88. ],
  89. 'options' => [
  90. //
  91. ],
  92. 'prefix' => 'swoole:',
  93. ],
  94. ],
  95. ];