I'm trying the use the already made event loop by Ratchet.
$server=IoServer::factory(new HttpServer(new WsServer(new class implements MessageComponentInterface{
public function __construct(){
// get the Ratchet Loop
}
public function onOpen(ConnectionInterface $conn){}
public function onMessage(ConnectionInterface $from, $msg){}
public function onClose(ConnectionInterface $conn){}
public function onError(ConnectionInterface $conn, \Exception $e){}
})),123);
I can get it by calling the $server->loop, but I can't pass it to the class constructor since $server is not accessible during the initialization of itself, I wondered if there is a better way of getting it?
You can instantiation a loop and pass it to
__construct
In this approach can't use
IoServer::factory
. Because you need to pass your own loop to$webSock
andIoServer