From f981d07bbc7cb8a5aad135878b269aa1c42cae4f Mon Sep 17 00:00:00 2001 From: Blue Date: Mon, 14 Aug 2023 10:31:28 +0200 Subject: [PATCH] server: add connectioninfo text --- server/src/bindings/ConnectionInfo.cpp | 18 ++++++++++++++++++ shared/V8ResourceImpl.cpp | 3 +-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/server/src/bindings/ConnectionInfo.cpp b/server/src/bindings/ConnectionInfo.cpp index 4940c4ce..e844d5bf 100644 --- a/server/src/bindings/ConnectionInfo.cpp +++ b/server/src/bindings/ConnectionInfo.cpp @@ -165,6 +165,23 @@ static void StaticGetByID(const v8::FunctionCallbackInfo& info) } } +static void GetText(v8::Local, const v8::PropertyCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT_RESOURCE(); + V8_GET_THIS_BASE_OBJECT(con, alt::IConnectionInfo); + + V8_RETURN_STRING(con->GetText()); +} + +static void SetText(v8::Local, v8::Local val, const v8::PropertyCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_GET_THIS_BASE_OBJECT(con, alt::IConnectionInfo); + V8_TO_STRING(val, text); + + con->SetText(text); +} + extern V8Class v8BaseObject; extern V8Class v8ConnectionInfo("ConnectionInfo", v8BaseObject, @@ -197,4 +214,5 @@ extern V8Class v8ConnectionInfo("ConnectionInfo", V8Helpers::SetAccessor(isolate, tpl, "socialClubName", &SocialClubNameGetter); V8Helpers::SetAccessor(isolate, tpl, "id", &ConnectionIDGetter); V8Helpers::SetAccessor(isolate, tpl, "cloudAuthHash", &CloudAuthHashGetter); + V8Helpers::SetAccessor(isolate, tpl, "text", &GetText, &SetText); }); diff --git a/shared/V8ResourceImpl.cpp b/shared/V8ResourceImpl.cpp index 4d42e7fc..de9429f8 100644 --- a/shared/V8ResourceImpl.cpp +++ b/shared/V8ResourceImpl.cpp @@ -52,7 +52,6 @@ bool V8ResourceImpl::Stop() resourceObjects.clear(); nextTickCallbacks.clear(); benchmarkTimers.clear(); - resourceObjects.clear(); localHandlers.clear(); remoteHandlers.clear(); @@ -318,7 +317,7 @@ v8::Local V8ResourceImpl::GetAllAudioOutputs() std::vector all = ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::AUDIO_OUTPUT); v8::Local jsAll = v8::Array::New(isolate, all.size()); - for (uint32_t i = 0; i < all.size(); ++i) jsAll->Set(GetContext(), i, GetBaseObjectOrNull(all[i])); + for(uint32_t i = 0; i < all.size(); ++i) jsAll->Set(GetContext(), i, GetBaseObjectOrNull(all[i])); jsAll->SetIntegrityLevel(GetContext(), v8::IntegrityLevel::kFrozen); return jsAll;