[英]Argument 1 passed to Ratchet\Session\SessionProvider::__construct() must implement interface Ratchet\Http\HttpServerInterface
I'm trying to use sessionProvider in Ratchet, the following is my shell script: 我正在尝试在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();
}
}
an error occur say: 发生错误说:
Argument 1 passed to Ratchet\\Session\\SessionProvider::__construct() must implement interface Ratchet\\Http\\HttpServerInterface, instance of App\\Http\\Controllers\\WebSockets\\Chat given
传递给Ratchet \\ Session \\ SessionProvider :: __ construct()的参数1必须实现接口Ratchet \\ Http \\ HttpServerInterface,App \\ Http \\ Controllers \\ WebSockets \\ Chat实例
how to solve this issue ! 如何解决这个问题!
my Chat class implement MessageComponentInterface
. 我的聊天类实现
MessageComponentInterface
。
ok after a long search i found the solution, even though ratchet document says the sessionProvider wrapped by WsServer, sessionProvider should Wrap the WsServer. 好的,经过漫长的搜索,我找到了解决方案,即使棘轮文件说的是WsServer 包装的sessionProvider,sessionProvider也应该包装 WsServer。
the warps should be like this instead: 扭曲应该是这样的:
IoServer::factory(
new HttpServer(
new SessionProvider(
new WsServer(
new Chat()
),
new Handler\MemcachedSessionHandler($memcached)
)
),
6502
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.