I have a server set up as so
$server = IoServer::factory(
new HttpServer(
new WsServer(
new Person()
)
),
8080
);
$server->run();
This works if the client uses ws://localhost:8080
.
What I would like to do is set a route like ws://localhost:8080/chat/{name}
ie. ws://localhost:8080/chat/Bob
and then be able to use Bob
as a variable in the onMessage()
function, ie.
$name = $route->name;
echo 'Welcome, ' . $name . '!'; // Welcome, Bob!
I have found examples like
$app = new Ratchet\App("localhost", 8080, '0.0.0.0', $loop);
$app->route('/chat', new Chat, array('*'));
$app->run();
but none mention a using a variable in the route.
How can this be accomplished?