简体   繁体   English

传递给Ratchet \\ Session \\ SessionProvider :: __ construct()的参数1必须实现接口Ratchet \\ Http \\ HttpServerInterface

[英]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.

相关问题 可捕获的致命错误:传递给“…\\ FormType :: __ construct()的参数1必须实现接口 - Catchable Fatal Error: Argument 1 passed to "…\FormType::__construct() must implement interface Laravel API - 传递给 TokenGuard::__construct() 的参数 1 必须实现接口 UserProvider - Laravel API - Argument 1 passed to TokenGuard::__construct() must implement interface UserProvider Symfony2:ContextErrorException:可捕获的致命错误:传递给[…] :: __ construct()的参数1必须实现接口[…]没有给出 - Symfony2: ContextErrorException: Catchable Fatal Error: Argument 1 passed to […]::__construct() must implement interface […] none given 棘轮会话存储 - Ratchet Session storage 传递给Twig_Extensions_Extension_Date :: __ construct()的参数1必须实现接口TranslatorInterface - Argument 1 passed to Twig_Extensions_Extension_Date::__construct() must implement interface TranslatorInterface 棘轮的Symfony会话处理程序 - Symfony Session Handler for Ratchet 如何在Ratchet中使用会话提供程序? - How to use session provider in Ratchet? 参数1传递给某事:: __ construct必须是 - Argument 1 passed to something::__construct must be 如何纠正棘轮中的[PHP致命错误:接口'棘轮\\消息组件接口'未找到] - How to rectify [PHP Fatal error: Interface 'Ratchet\MessageComponentInterface' not found ] in ratchet __construct()必须实现接口错误 - __construct() must implement interface error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM