【发布时间】:2018-11-23 11:58:03
【问题描述】:
我正在尝试在 Ratchet 中使用 sessionProvider,以下是我的 shell 脚本:
namespace App\Console\Commands;
use Ratchet\Session\SessionProvider;
use Illuminate\Console\Command;
use Ratchet\Server\IoServer;
use App\Http\Controllers\WebSockets\Chat;
use Ratchet\WebSocket\WsServer;
use Ratchet\Http\HttpServer;
use Symfony\Component\HttpFoundation\Session\Storage\Handler;
class ChatShell extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'command:chat';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$memcached = new \Memcached();
$server = IoServer::factory(
new HttpServer(
new WsServer(
new SessionProvider(
new Chat(),
new Handler\MemcachedSessionHandler($memcached)
)
)
),
6502
);
$server->run();
}
}
发生错误说:
传递给 Ratchet\Session\SessionProvider::__construct() 的参数 1 必须实现接口 Ratchet\Http\HttpServerInterface,给定 App\Http\Controllers\WebSockets\Chat 的实例
如何解决这个问题!
我的聊天类实现MessageComponentInterface。
【问题讨论】:
标签: php laravel session websocket ratchet