|
@@ -82,6 +82,7 @@ class GameClient {
|
|
|
echo "是否成功获取信息: " .$userResponse->hasUserInfo() . "\n";
|
|
|
if ($userResponse->hasUserInfo()) {
|
|
|
$this->enterHall($userResponse->getUserInfo()->getUserId());
|
|
|
+ $this->startListening();
|
|
|
}
|
|
|
|
|
|
} catch (Exception $e) {
|
|
@@ -100,10 +101,15 @@ class GameClient {
|
|
|
echo "成功进入大厅!\n";
|
|
|
echo "大厅玩家数: " . $response->getSuccess() . "\n";
|
|
|
});
|
|
|
+ }
|
|
|
|
|
|
+ private function startListening() {
|
|
|
+ if (!$this->client) {
|
|
|
+ throw new Exception("WebSocket连接未建立");
|
|
|
+ }
|
|
|
+ echo "开始监听WebSocket消息...\n";
|
|
|
$this->client->startListening();
|
|
|
}
|
|
|
-
|
|
|
private function enterHall($userId) {
|
|
|
if (!$this->client) {
|
|
|
throw new Exception("WebSocket连接未建立");
|