composer require jscorptech/websocket
php artisan verdor:publish --tag=websocket
<?php
namespace App\Http\Handlers;
use JscorpTech\Websocket\Interfaces\WebsocketInterface;
class WebsocketHandler implements WebsocketInterface
{
public function onConnect($connection, $service): void
{
// TODO: Implement onConnect() method.
}
public function onMessage($connection, $message, $service)
{
// TODO: Implement onMessage() method.
}
public function onClose($connection, $service)
{
// TODO: Implement onClose() method.
}
}
<?php
use App\Http\Handlers\WebsocketHandler;
return [
"handler" => WebsocketHandler::class, // Yuqorida yaratilgan handler class
"host" => "0.0.0.0", // host
"port" => 9501, // port
"redis" => [
"host" => "127.0.0.1", // redis host
"port" => 6379, // redis port
"password" => null, // redis password
]
];
php artisan jst:websocket start