Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持配置更多路由项 #443

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ int Client::run() {
std::lock_guard lock(this->runningMutex);
this->running = true;
this->localP2PDisabled = false;
this->sysRtTable.clear();

if (startWsThread()) {
spdlog::critical("start websocket client thread failed");
Expand Down Expand Up @@ -680,7 +681,6 @@ void Client::handleSysRtMessage(WebSocketMessage &message) {
SysRouteMessage *header = (SysRouteMessage *)message.buffer.c_str();
SysRouteItem *rt = header->rtTable;
std::unique_lock lock(this->sysRtTableMutex);
this->sysRtTable.clear();
for (uint8_t idx = 0; idx < header->size; ++idx) {
SysRouteEntry entry;
entry.dst = Address::netToHost(rt[idx].dest);
Expand Down
6 changes: 6 additions & 0 deletions src/core/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,12 @@ void Server::updateClientRoute(WebSocketMessage &message, uint32_t client) {
message.buffer.append((char *)(&item), sizeof(item));
header->size += 1;
}
// 100 条路由报文大小是 1204 字节,超过 100 条后分批发送
if (header->size > 100) {
this->ws.write(message);
message.buffer.resize(sizeof(SysRouteMessage));
header->size = 0;
}
}

if (header->size > 0) {
Expand Down