Аргумент 1, передаваемый в Ratchet \ Session \ SessionProvider :: __ construct (), должен реализовывать интерфейс Ratchet \ Http \ HttpServerInterface - PullRequest
0 голосов
/ 23 ноября 2018

Я пытаюсь использовать sessionProvider в Ratchet, вот мой скрипт оболочки:

    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();
    }
}

произошла ошибка, скажем:

Аргумент 1 передан в Ratchet \ Session\ SessionProvider :: __ construct () должен реализовывать интерфейс Ratchet \ Http \ HttpServerInterface, экземпляр App \ Http \ Controllers \ WebSockets \ Chat, указанный

, как решить эту проблему!

myРеализация класса чата MessageComponentInterface.

1 Ответ

0 голосов
/ 23 ноября 2018

хорошо, после долгого поиска я нашел решение, даже если документ с храповым механизмом говорит, что sessionProvider обернут WsServer, sessionProvider должен Wrap WsServer.

основыдолжно быть вот так:

IoServer::factory(
        new HttpServer(
            new SessionProvider(
                new WsServer(
                    new Chat()
                ),
                new Handler\MemcachedSessionHandler($memcached)
            )
        ),
        6502
    );
...