Skip to content

Commit

Permalink
Split client channels into hi and lo for JS
Browse files Browse the repository at this point in the history
  • Loading branch information
ksmit799 committed Apr 8, 2024
1 parent fae8d24 commit 2347f90
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/clientagent/client_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,10 @@ void ClientAgent::HandleWeb(ws28::Client *client, nlohmann::json &data) {
nlohmann::json clientInfo = nlohmann::json::array();
for (const auto &participant : _participants) {
clientInfo.push_back({
{"channel", participant->GetChannel()},
// We have to do this terribleness because JavaScript doesn't support
// uint64's (see handling 'client' messages below.)
{"channelHi", (participant->GetChannel() >> 32) & 0xFFFFFFFF},
{"channelLo", participant->GetChannel() & 0xFFFFFFFF},
{"ip", participant->GetRemoteAddress().ip},
{"port", participant->GetRemoteAddress().port},
{"state", participant->GetAuthState()},
Expand All @@ -384,7 +387,10 @@ void ClientAgent::HandleWeb(ws28::Client *client, nlohmann::json &data) {
{"clients", clientInfo},
});
} else if (data["msg"] == "client") {
auto channel = data["channel"].template get<uint64_t>();
// We have to do this terribleness because JavaScript doesn't support
// uint64's.
auto channel = (uint64_t)data["channelHi"].template get<uint32_t>() << 32 |
data["channelLo"].template get<uint32_t>();

// Try to find a matching client for the provided channel.
auto participant =
Expand Down Expand Up @@ -418,7 +424,7 @@ void ClientAgent::HandleWeb(ws28::Client *client, nlohmann::json &data) {
// Build an active interests array.
nlohmann::json interests = nlohmann::json::array();
for (const auto &interest : (*participant)->GetInterests()) {
ownedObjs.push_back({{"id", interest.first},
interests.push_back({{"id", interest.first},
{"parent", interest.second.parent},
{"zones", interest.second.zones}});
}
Expand Down

0 comments on commit 2347f90

Please sign in to comment.