Skip to content

Commit

Permalink
server: add connectioninfo text
Browse files Browse the repository at this point in the history
  • Loading branch information
C0kkie committed Aug 14, 2023
1 parent f53395e commit f981d07
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
18 changes: 18 additions & 0 deletions server/src/bindings/ConnectionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,23 @@ static void StaticGetByID(const v8::FunctionCallbackInfo<v8::Value>& info)
}
}

static void GetText(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& 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::String>, v8::Local<v8::Value> val, const v8::PropertyCallbackInfo<void>& 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,
Expand Down Expand Up @@ -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);
});
3 changes: 1 addition & 2 deletions shared/V8ResourceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ bool V8ResourceImpl::Stop()
resourceObjects.clear();
nextTickCallbacks.clear();
benchmarkTimers.clear();
resourceObjects.clear();

localHandlers.clear();
remoteHandlers.clear();
Expand Down Expand Up @@ -318,7 +317,7 @@ v8::Local<v8::Array> V8ResourceImpl::GetAllAudioOutputs()
std::vector<IBaseObject*> all = ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::AUDIO_OUTPUT);
v8::Local<v8::Array> 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;
Expand Down

0 comments on commit f981d07

Please sign in to comment.