|
@@ -6,8 +6,10 @@ require_once './msg.php';
|
|
|
|
|
|
use App\WebSocketClient;
|
|
|
use Common_pack\EnterHall;
|
|
|
+use Common_pack\ReqFriendList;
|
|
|
use Common_pack\ReqLogin;
|
|
|
use Common_pack\ResEnterHall;
|
|
|
+use Common_pack\ResFriendList;
|
|
|
use Common_pack\ResHeartBeat;
|
|
|
use Common_pack\ResLogin;
|
|
|
use Exception;
|
|
@@ -27,6 +29,14 @@ class GameClient {
|
|
|
public function close() {
|
|
|
echo "命令调用了 close \n";
|
|
|
}
|
|
|
+
|
|
|
+ public function getFriends(){
|
|
|
+ $userResponse = new ReqFriendList();
|
|
|
+ $userResponse->setUserId($this->userId);
|
|
|
+ $binaryData = $userResponse->serializeToString();
|
|
|
+ $this->client->sendBinary(MsgID::REQFRIENDLIST, $binaryData);
|
|
|
+ echo "已发送获取好友列表请求\n";
|
|
|
+ }
|
|
|
public function outGame(){
|
|
|
echo "命令调用了 outGame \n";
|
|
|
}
|
|
@@ -122,6 +132,13 @@ class GameClient {
|
|
|
// echo "心跳:".$response->getMsg();
|
|
|
// echo "\n";
|
|
|
});
|
|
|
+
|
|
|
+ $this->client->on(MsgID::RESFRIENDLIST, function($binaryData) {
|
|
|
+ $response = new ResFriendList();
|
|
|
+ $response->mergeFromString($binaryData);
|
|
|
+ echo "获取好友列表:".$response->getList();
|
|
|
+ echo "\n";
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
private function startListening() {
|