public function testEvent() { $loop = $this->loop; $client = new Client($loop, $this->host, $this->port, $this->path); $server = $this->server; $this->server->setOnSubscribeCallback(function (ConnectionInterface $conn, $topic) use($server) { /** @var \Ratchet\Wamp\Topic $topic */ $server->broadcast($topic->getId(), 'this is my message'); }); $response = null; $client->setOnEventCallback(function (Client $conn, $topic, $data) use(&$response, $loop) { $response = array('topic' => $topic, 'message' => $data); $loop->stop(); }); $client->setOnWelcomeCallback(function (Client $conn, $data) { $conn->subscribe('test_topic'); }); $loop->run(); $this->assertEquals('test_topic', $response['topic']); $this->assertEquals('this is my message', $response['message']); }