正在显示
6 个修改的文件
包含
0 行增加
和
403 行删除
app/Broadcasting/WebSocketChannel.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Broadcasting; | ||
| 4 | - | ||
| 5 | -use App\Models\User\User; | ||
| 6 | - | ||
| 7 | -class WebSocketChannel | ||
| 8 | -{ | ||
| 9 | - /** | ||
| 10 | - * Create a new channel instance. | ||
| 11 | - * | ||
| 12 | - * @return void | ||
| 13 | - */ | ||
| 14 | - public function __construct() | ||
| 15 | - { | ||
| 16 | - // | ||
| 17 | - } | ||
| 18 | - | ||
| 19 | - /** | ||
| 20 | - * Authenticate the user's access to the channel. | ||
| 21 | - * | ||
| 22 | - * @param \App\Models\User\User $user | ||
| 23 | - * @return array|bool | ||
| 24 | - */ | ||
| 25 | - public function join(User $user) | ||
| 26 | - { | ||
| 27 | - // | ||
| 28 | - } | ||
| 29 | -} |
app/Events/WebSocketMessage.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Events; | ||
| 4 | - | ||
| 5 | -use Illuminate\Broadcasting\Channel; | ||
| 6 | -use Illuminate\Broadcasting\InteractsWithSockets; | ||
| 7 | -use Illuminate\Broadcasting\PresenceChannel; | ||
| 8 | -use Illuminate\Broadcasting\PrivateChannel; | ||
| 9 | -use Illuminate\Contracts\Broadcasting\ShouldBroadcast; | ||
| 10 | -use Illuminate\Foundation\Events\Dispatchable; | ||
| 11 | -use Illuminate\Queue\SerializesModels; | ||
| 12 | - | ||
| 13 | -class WebSocketMessage implements ShouldBroadcast | ||
| 14 | -{ | ||
| 15 | - use Dispatchable, InteractsWithSockets, SerializesModels; | ||
| 16 | - | ||
| 17 | - public $message; | ||
| 18 | - | ||
| 19 | - public function __construct($message) | ||
| 20 | - { | ||
| 21 | - $this->message = $message; | ||
| 22 | - } | ||
| 23 | - | ||
| 24 | - public function broadcastOn() | ||
| 25 | - { | ||
| 26 | - return new Channel('websocket-channel'); | ||
| 27 | - } | ||
| 28 | -} |
app/Events/WebSocketMessage.php~HEAD
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Events; | ||
| 4 | - | ||
| 5 | -use Illuminate\Broadcasting\Channel; | ||
| 6 | -use Illuminate\Broadcasting\InteractsWithSockets; | ||
| 7 | -use Illuminate\Broadcasting\PresenceChannel; | ||
| 8 | -use Illuminate\Broadcasting\PrivateChannel; | ||
| 9 | -use Illuminate\Contracts\Broadcasting\ShouldBroadcast; | ||
| 10 | -use Illuminate\Foundation\Events\Dispatchable; | ||
| 11 | -use Illuminate\Queue\SerializesModels; | ||
| 12 | - | ||
| 13 | -class WebSocketMessage | ||
| 14 | -{ | ||
| 15 | - use Dispatchable, InteractsWithSockets, SerializesModels; | ||
| 16 | - | ||
| 17 | - /** | ||
| 18 | - * Create a new event instance. | ||
| 19 | - * | ||
| 20 | - * @return void | ||
| 21 | - */ | ||
| 22 | - public function __construct() | ||
| 23 | - { | ||
| 24 | - // | ||
| 25 | - } | ||
| 26 | - | ||
| 27 | - /** | ||
| 28 | - * Get the channels the event should broadcast on. | ||
| 29 | - * | ||
| 30 | - * @return \Illuminate\Broadcasting\Channel|array | ||
| 31 | - */ | ||
| 32 | - public function broadcastOn() | ||
| 33 | - { | ||
| 34 | - return new PrivateChannel('channel-name'); | ||
| 35 | - } | ||
| 36 | -} |
config/broadcasting.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -return [ | ||
| 4 | - | ||
| 5 | - /* | ||
| 6 | - |-------------------------------------------------------------------------- | ||
| 7 | - | Default Broadcaster | ||
| 8 | - |-------------------------------------------------------------------------- | ||
| 9 | - | | ||
| 10 | - | This option controls the default broadcaster that will be used by the | ||
| 11 | - | framework when an event needs to be broadcast. You may set this to | ||
| 12 | - | any of the connections defined in the "connections" array below. | ||
| 13 | - | | ||
| 14 | - | Supported: "pusher", "ably", "redis", "log", "null" | ||
| 15 | - | | ||
| 16 | - */ | ||
| 17 | - | ||
| 18 | - 'default' => env('BROADCAST_DRIVER', 'swoole'), | ||
| 19 | - | ||
| 20 | - /* | ||
| 21 | - |-------------------------------------------------------------------------- | ||
| 22 | - | Broadcast Connections | ||
| 23 | - |-------------------------------------------------------------------------- | ||
| 24 | - | | ||
| 25 | - | Here you may define all of the broadcast connections that will be used | ||
| 26 | - | to broadcast events to other systems or over websockets. Samples of | ||
| 27 | - | each available type of connection are provided inside this array. | ||
| 28 | - | | ||
| 29 | - */ | ||
| 30 | - | ||
| 31 | - 'connections' => [ | ||
| 32 | - 'pusher' => [ | ||
| 33 | - 'driver' => 'pusher', | ||
| 34 | - 'key' => env('PUSHER_APP_KEY'), | ||
| 35 | - 'secret' => env('PUSHER_APP_SECRET'), | ||
| 36 | - 'app_id' => env('PUSHER_APP_ID'), | ||
| 37 | - 'options' => [ | ||
| 38 | - 'cluster' => env('PUSHER_APP_CLUSTER'), | ||
| 39 | - 'useTLS' => true, | ||
| 40 | - ], | ||
| 41 | - ], | ||
| 42 | - 'swoole' => [ | ||
| 43 | - 'driver' => 'swoole', | ||
| 44 | - 'queue' => 'default', // 队列名 | ||
| 45 | - ], | ||
| 46 | - 'ably' => [ | ||
| 47 | - 'driver' => 'ably', | ||
| 48 | - 'key' => env('ABLY_KEY'), | ||
| 49 | - ], | ||
| 50 | - | ||
| 51 | - 'redis' => [ | ||
| 52 | - 'driver' => 'redis', | ||
| 53 | - 'connection' => 'default', | ||
| 54 | - ], | ||
| 55 | - | ||
| 56 | - 'log' => [ | ||
| 57 | - 'driver' => 'log', | ||
| 58 | - ], | ||
| 59 | - | ||
| 60 | - 'null' => [ | ||
| 61 | - 'driver' => 'null', | ||
| 62 | - ], | ||
| 63 | - | ||
| 64 | - ], | ||
| 65 | - | ||
| 66 | -]; |
config/swoole_http.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -return [ | ||
| 4 | - /* | ||
| 5 | - |-------------------------------------------------------------------------- | ||
| 6 | - | HTTP server configurations. | ||
| 7 | - |-------------------------------------------------------------------------- | ||
| 8 | - | | ||
| 9 | - | @see https://www.swoole.co.uk/docs/modules/swoole-server/configuration | ||
| 10 | - | | ||
| 11 | - */ | ||
| 12 | - 'server' => [ | ||
| 13 | - 'host' => env('SWOOLE_HTTP_HOST', '127.0.0.1'), | ||
| 14 | - 'port' => env('SWOOLE_HTTP_PORT', '1215'), | ||
| 15 | - 'public_path' => base_path('public'), | ||
| 16 | - // Determine if to use swoole to respond request for static files | ||
| 17 | - 'handle_static_files' => env('SWOOLE_HANDLE_STATIC', true), | ||
| 18 | - 'access_log' => env('SWOOLE_HTTP_ACCESS_LOG', false), | ||
| 19 | - // You must add --enable-openssl while compiling Swoole | ||
| 20 | - // Put `SWOOLE_SOCK_TCP | SWOOLE_SSL` if you want to enable SSL | ||
| 21 | - 'socket_type' => SWOOLE_SOCK_TCP, | ||
| 22 | - 'process_type' => SWOOLE_PROCESS, | ||
| 23 | - 'options' => [ | ||
| 24 | - 'pid_file' => env('SWOOLE_HTTP_PID_FILE', base_path('storage/logs/swoole_http.pid')), | ||
| 25 | - 'log_file' => env('SWOOLE_HTTP_LOG_FILE', base_path('storage/logs/swoole_http.log')), | ||
| 26 | - 'daemonize' => env('SWOOLE_HTTP_DAEMONIZE', false), | ||
| 27 | - // Normally this value should be 1~4 times larger according to your cpu cores. | ||
| 28 | - 'reactor_num' => env('SWOOLE_HTTP_REACTOR_NUM', swoole_cpu_num()), | ||
| 29 | - 'worker_num' => env('SWOOLE_HTTP_WORKER_NUM', swoole_cpu_num()), | ||
| 30 | - 'task_worker_num' => env('SWOOLE_HTTP_TASK_WORKER_NUM', swoole_cpu_num()), | ||
| 31 | - // The data to receive can't be larger than buffer_output_size. | ||
| 32 | - 'package_max_length' => 20 * 1024 * 1024, | ||
| 33 | - // The data to send can't be larger than buffer_output_size. | ||
| 34 | - 'buffer_output_size' => 10 * 1024 * 1024, | ||
| 35 | - // Max buffer size for socket connections | ||
| 36 | - 'socket_buffer_size' => 128 * 1024 * 1024, | ||
| 37 | - // Worker will restart after processing this number of requests | ||
| 38 | - 'max_request' => 3000, | ||
| 39 | - // Enable coroutine send | ||
| 40 | - 'send_yield' => true, | ||
| 41 | - // You must add --enable-openssl while compiling Swoole | ||
| 42 | - 'ssl_cert_file' => null, | ||
| 43 | - 'ssl_key_file' => null, | ||
| 44 | - ], | ||
| 45 | - ], | ||
| 46 | - | ||
| 47 | - /* | ||
| 48 | - |-------------------------------------------------------------------------- | ||
| 49 | - | Enable to turn on websocket server. | ||
| 50 | - |-------------------------------------------------------------------------- | ||
| 51 | - */ | ||
| 52 | - 'websocket' => [ | ||
| 53 | - 'enabled' => env('SWOOLE_HTTP_WEBSOCKET', true), | ||
| 54 | - ], | ||
| 55 | - | ||
| 56 | - /* | ||
| 57 | - |-------------------------------------------------------------------------- | ||
| 58 | - | Hot reload configuration | ||
| 59 | - |-------------------------------------------------------------------------- | ||
| 60 | - */ | ||
| 61 | - 'hot_reload' => [ | ||
| 62 | - 'enabled' => env('SWOOLE_HOT_RELOAD_ENABLE', false), | ||
| 63 | - 'recursively' => env('SWOOLE_HOT_RELOAD_RECURSIVELY', true), | ||
| 64 | - 'directory' => env('SWOOLE_HOT_RELOAD_DIRECTORY', base_path()), | ||
| 65 | - 'log' => env('SWOOLE_HOT_RELOAD_LOG', true), | ||
| 66 | - 'filter' => env('SWOOLE_HOT_RELOAD_FILTER', '.php'), | ||
| 67 | - ], | ||
| 68 | - | ||
| 69 | - /* | ||
| 70 | - |-------------------------------------------------------------------------- | ||
| 71 | - | Console output will be transferred to response content if enabled. | ||
| 72 | - |-------------------------------------------------------------------------- | ||
| 73 | - */ | ||
| 74 | - 'ob_output' => env('SWOOLE_OB_OUTPUT', true), | ||
| 75 | - | ||
| 76 | - /* | ||
| 77 | - |-------------------------------------------------------------------------- | ||
| 78 | - | Pre-resolved instances here will be resolved when sandbox created. | ||
| 79 | - |-------------------------------------------------------------------------- | ||
| 80 | - */ | ||
| 81 | - 'pre_resolved' => [ | ||
| 82 | - 'view', 'files', 'session', 'session.store', 'routes', | ||
| 83 | - 'db', 'db.factory', 'cache', 'cache.store', 'config', 'cookie', | ||
| 84 | - 'encrypter', 'hash', 'router', 'translator', 'url', 'log', | ||
| 85 | - ], | ||
| 86 | - | ||
| 87 | - /* | ||
| 88 | - |-------------------------------------------------------------------------- | ||
| 89 | - | Instances here will be cleared on every request. | ||
| 90 | - |-------------------------------------------------------------------------- | ||
| 91 | - */ | ||
| 92 | - 'instances' => [ | ||
| 93 | - 'auth', | ||
| 94 | - ], | ||
| 95 | - | ||
| 96 | - /* | ||
| 97 | - |-------------------------------------------------------------------------- | ||
| 98 | - | Providers here will be registered on every request. | ||
| 99 | - |-------------------------------------------------------------------------- | ||
| 100 | - */ | ||
| 101 | - 'providers' => [ | ||
| 102 | - Illuminate\Pagination\PaginationServiceProvider::class, | ||
| 103 | - ], | ||
| 104 | - | ||
| 105 | - /* | ||
| 106 | - |-------------------------------------------------------------------------- | ||
| 107 | - | Resetters for sandbox app. | ||
| 108 | - |-------------------------------------------------------------------------- | ||
| 109 | - */ | ||
| 110 | - 'resetters' => [ | ||
| 111 | - SwooleTW\Http\Server\Resetters\ResetConfig::class, | ||
| 112 | - SwooleTW\Http\Server\Resetters\ResetSession::class, | ||
| 113 | - SwooleTW\Http\Server\Resetters\ResetCookie::class, | ||
| 114 | - SwooleTW\Http\Server\Resetters\ClearInstances::class, | ||
| 115 | - SwooleTW\Http\Server\Resetters\BindRequest::class, | ||
| 116 | - SwooleTW\Http\Server\Resetters\RebindKernelContainer::class, | ||
| 117 | - SwooleTW\Http\Server\Resetters\RebindRouterContainer::class, | ||
| 118 | - SwooleTW\Http\Server\Resetters\RebindViewContainer::class, | ||
| 119 | - SwooleTW\Http\Server\Resetters\ResetProviders::class, | ||
| 120 | - ], | ||
| 121 | - | ||
| 122 | - /* | ||
| 123 | - |-------------------------------------------------------------------------- | ||
| 124 | - | Define your swoole tables here. | ||
| 125 | - | | ||
| 126 | - | @see https://www.swoole.co.uk/docs/modules/swoole-table | ||
| 127 | - |-------------------------------------------------------------------------- | ||
| 128 | - */ | ||
| 129 | - 'tables' => [ | ||
| 130 | - // 'table_name' => [ | ||
| 131 | - // 'size' => 1024, | ||
| 132 | - // 'columns' => [ | ||
| 133 | - // ['name' => 'column_name', 'type' => Table::TYPE_STRING, 'size' => 1024], | ||
| 134 | - // ] | ||
| 135 | - // ], | ||
| 136 | - ], | ||
| 137 | -]; |
config/swoole_websocket.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -return [ | ||
| 4 | - /* | ||
| 5 | - |-------------------------------------------------------------------------- | ||
| 6 | - | Websocket handler for onOpen and onClose callback | ||
| 7 | - | Replace this handler if you want to customize your websocket handler | ||
| 8 | - |-------------------------------------------------------------------------- | ||
| 9 | - */ | ||
| 10 | - 'handler' => SwooleTW\Http\Websocket\SocketIO\WebsocketHandler::class, | ||
| 11 | - | ||
| 12 | - /* | ||
| 13 | - |-------------------------------------------------------------------------- | ||
| 14 | - | Default frame parser | ||
| 15 | - | Replace it if you want to customize your websocket payload | ||
| 16 | - |-------------------------------------------------------------------------- | ||
| 17 | - */ | ||
| 18 | - 'parser' => SwooleTW\Http\Websocket\SocketIO\SocketIOParser::class, | ||
| 19 | - | ||
| 20 | - /* | ||
| 21 | - |-------------------------------------------------------------------------- | ||
| 22 | - | Websocket route file path | ||
| 23 | - |-------------------------------------------------------------------------- | ||
| 24 | - */ | ||
| 25 | - 'route_file' => base_path('routes/websocket.php'), | ||
| 26 | - | ||
| 27 | - /* | ||
| 28 | - |-------------------------------------------------------------------------- | ||
| 29 | - | Default middleware for on connect request | ||
| 30 | - |-------------------------------------------------------------------------- | ||
| 31 | - */ | ||
| 32 | - 'middleware' => [ | ||
| 33 | - // SwooleTW\Http\Websocket\Middleware\DecryptCookies::class, | ||
| 34 | - // SwooleTW\Http\Websocket\Middleware\StartSession::class, | ||
| 35 | - // SwooleTW\Http\Websocket\Middleware\Authenticate::class, | ||
| 36 | - ], | ||
| 37 | - | ||
| 38 | - /* | ||
| 39 | - |-------------------------------------------------------------------------- | ||
| 40 | - | Websocket handler for customized onHandShake callback | ||
| 41 | - |-------------------------------------------------------------------------- | ||
| 42 | - */ | ||
| 43 | - 'handshake' => [ | ||
| 44 | - 'enabled' => false, | ||
| 45 | - 'handler' => SwooleTW\Http\Websocket\HandShakeHandler::class, | ||
| 46 | - ], | ||
| 47 | - | ||
| 48 | - /* | ||
| 49 | - |-------------------------------------------------------------------------- | ||
| 50 | - | Default websocket driver | ||
| 51 | - |-------------------------------------------------------------------------- | ||
| 52 | - */ | ||
| 53 | - 'default' => 'table', | ||
| 54 | - | ||
| 55 | - /* | ||
| 56 | - |-------------------------------------------------------------------------- | ||
| 57 | - | Websocket client's heartbeat interval (ms) | ||
| 58 | - |-------------------------------------------------------------------------- | ||
| 59 | - */ | ||
| 60 | - 'ping_interval' => 25000, | ||
| 61 | - | ||
| 62 | - /* | ||
| 63 | - |-------------------------------------------------------------------------- | ||
| 64 | - | Websocket client's heartbeat interval timeout (ms) | ||
| 65 | - |-------------------------------------------------------------------------- | ||
| 66 | - */ | ||
| 67 | - 'ping_timeout' => 60000, | ||
| 68 | - | ||
| 69 | - /* | ||
| 70 | - |-------------------------------------------------------------------------- | ||
| 71 | - | Room drivers mapping | ||
| 72 | - |-------------------------------------------------------------------------- | ||
| 73 | - */ | ||
| 74 | - 'drivers' => [ | ||
| 75 | - 'table' => SwooleTW\Http\Websocket\Rooms\TableRoom::class, | ||
| 76 | - 'redis' => SwooleTW\Http\Websocket\Rooms\RedisRoom::class, | ||
| 77 | - ], | ||
| 78 | - | ||
| 79 | - /* | ||
| 80 | - |-------------------------------------------------------------------------- | ||
| 81 | - | Room drivers settings | ||
| 82 | - |-------------------------------------------------------------------------- | ||
| 83 | - */ | ||
| 84 | - 'settings' => [ | ||
| 85 | - | ||
| 86 | - 'table' => [ | ||
| 87 | - 'room_rows' => 4096, | ||
| 88 | - 'room_size' => 2048, | ||
| 89 | - 'client_rows' => 8192, | ||
| 90 | - 'client_size' => 2048, | ||
| 91 | - ], | ||
| 92 | - | ||
| 93 | - 'redis' => [ | ||
| 94 | - 'server' => [ | ||
| 95 | - 'host' => env('REDIS_HOST', '127.0.0.1'), | ||
| 96 | - 'password' => env('REDIS_PASSWORD', null), | ||
| 97 | - 'port' => env('REDIS_PORT', 6379), | ||
| 98 | - 'database' => 0, | ||
| 99 | - 'persistent' => true, | ||
| 100 | - ], | ||
| 101 | - 'options' => [ | ||
| 102 | - // | ||
| 103 | - ], | ||
| 104 | - 'prefix' => 'swoole:', | ||
| 105 | - ], | ||
| 106 | - ], | ||
| 107 | -]; |
-
请 注册 或 登录 后发表评论