add updateFriendList from network

This commit is contained in:
xyz
2025-06-11 19:38:09 +08:00
parent 24536ca80f
commit e4ec73b510
8 changed files with 118 additions and 4 deletions

View File

@ -143,4 +143,36 @@ namespace network {
LOG() << "获取个人信息->响应处理完毕 requestId" << req.requestId();
});
}
void NetClient::getFriendList(const QString loginSessionId)
{
//通过protobuf构造body
bite_im::GetFriendListReq req;
req.setRequestId(makeRequestId());
req.setSessionId(loginSessionId);
QByteArray body = req.serialize(&serializer);
LOG() << "获取好友列表->发送请求 requestId=" << req.requestId() << ", loginSessionId= " << loginSessionId;
//发送HTTP请求
QNetworkReply* httpResp = this->sendHttpRequest("/service/friend/get_friend_list", body);
//处理响应
connect(httpResp, &QNetworkReply::finished, this, [=]() {
//解析响应
bool ok = false;
QString reason;
auto friendListResp = this->handleHttpResponse<bite_im::GetFriendListRsp>(httpResp, &ok, &reason);
if (!ok) {
LOG() << "获取好友列表->失败 requestId= " << req.requestId() << ", reason= " << reason;
}
LOG() << "获取好友列表->成功";
//把结果保存在DataCenter中
dataCenter->resetFriendList(friendListResp);
// 发送信号
emit dataCenter->getFriendListDone();
});
}
} //end namespace network

View File

@ -75,10 +75,12 @@ namespace network {
//释放httpResp对象
httpResp->deleteLater();
*ok = true;
return respObj;
}
void getMyself(const QString& loginSessionId);
void getFriendList(const QString loginSessionId);
private:
model::DataCenter* dataCenter;