Skip to content

Commit

Permalink
支持配置更多路由项
Browse files Browse the repository at this point in the history
  • Loading branch information
lanthora committed Oct 3, 2024
1 parent 56da326 commit 9ce6780
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit 9ce6780

Please sign in to comment.