With the following:
$client = new \Rx\Websocket\Client('ws://127.0.0.1:9090/ws');
$client->subscribe(function (MessageSubject $ms) {
$disp = $ms->subscribe();
addTimer(2, function () use ($disp) {
echo "Dispose...\n";
$disp->dispose();
});
});
The websocket should close when there are no more subscriptions.