mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-10-15 00:09:39 +08:00
[fix] report mobile client info after identity login
This commit is contained in:
@@ -136,6 +136,14 @@ struct Session {
|
||||
|
||||
void Signal(SignalStatus status, const char*, size_t, void* user) {
|
||||
auto* ctx = static_cast<CallbackContext*>(user);
|
||||
if (!ctx->controller && status == SignalStatus::SignalConnected &&
|
||||
!ctx->owner->stopping && ctx->owner->identity) {
|
||||
// Report after every identity login, including reconnects. The server
|
||||
// ignores client_info sent through the temporary C- controller peer.
|
||||
constexpr char info[] =
|
||||
R"({"type":"client_info","version":"android-native","platform":"android"})";
|
||||
SendSignalMessage(ctx->owner->identity, info, sizeof(info) - 1);
|
||||
}
|
||||
if (!ctx->controller && ctx->owner->signal_status.exchange(status) != status)
|
||||
++ctx->owner->signal_generation;
|
||||
const auto generation = ctx->owner->signal_generation.load();
|
||||
@@ -339,8 +347,6 @@ extern "C" JNIEXPORT jboolean JNICALL JNI_METHOD(nConnect)(
|
||||
}
|
||||
extern "C" JNIEXPORT void JNICALL JNI_METHOD(nReady)(JNIEnv*, jclass, jlong handle) {
|
||||
auto* s = From(handle); if (!s || !s->controller) return;
|
||||
const std::string info = R"({"type":"client_info","version":"android-native","platform":"android"})";
|
||||
SendSignalMessage(s->controller, info.data(), info.size());
|
||||
auto action = MakeHostInformation("CrossDesk Android", {}, false, "1.6.0", HostPlatform::Android);
|
||||
s->Send(kControlStream, action.to_json()); FreeRemoteAction(action);
|
||||
}
|
||||
|
||||
@@ -1195,6 +1195,15 @@ Params MakeParams(const RTCState &state, const std::string &user_id,
|
||||
self->_state->presence_requests.clear();
|
||||
if (role == PeerRole::Identity) {
|
||||
self->_state->identity_ready = state == CrossDeskSignalStateConnected;
|
||||
if (self->_state->identity_ready && self->_state->identity_peer) {
|
||||
// The server records client_info on the persistent identity peer,
|
||||
// before any remote session starts and again after reconnecting.
|
||||
constexpr char client_info[] =
|
||||
"{\"type\":\"client_info\",\"version\":\"ios-native\","
|
||||
"\"platform\":\"ios\"}";
|
||||
SendSignalMessage(self->_state->identity_peer, client_info,
|
||||
sizeof(client_info) - 1);
|
||||
}
|
||||
if (state == CrossDeskSignalStateFailed &&
|
||||
!self->_state->identity_with_password.empty() &&
|
||||
!self->_state->identity_recovery_attempted) {
|
||||
@@ -1377,11 +1386,6 @@ Params MakeParams(const RTCState &state, const std::string &user_id,
|
||||
!self->_state->controller_peer) {
|
||||
return;
|
||||
}
|
||||
constexpr char client_info[] =
|
||||
"{\"type\":\"client_info\",\"version\":\"ios-native\","
|
||||
"\"platform\":\"ios\"}";
|
||||
SendSignalMessage(self->_state->controller_peer, client_info,
|
||||
sizeof(client_info) - 1);
|
||||
const std::string controller_name =
|
||||
self->_state->identity_base.empty()
|
||||
? "iPhone"
|
||||
|
||||
Reference in New Issue
Block a user