From 1ad1e5fb40bd80ccd0bcf27301ea3417748b1e40 Mon Sep 17 00:00:00 2001 From: xshady <54737754+xxshady@users.noreply.github.com> Date: Tue, 8 Aug 2023 19:38:31 +0300 Subject: [PATCH 01/10] server|shared: Move dimension constants to shared (#293) --- server/src/bindings/Main.cpp | 2 -- shared/bindings/BindingsMain.cpp | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/bindings/Main.cpp b/server/src/bindings/Main.cpp index 8a371cc6..3c4515d1 100644 --- a/server/src/bindings/Main.cpp +++ b/server/src/bindings/Main.cpp @@ -646,6 +646,4 @@ extern V8Module V8Helpers::RegisterFunc(exports, "setVoiceExternal", &SetVoiceExternal); V8_OBJECT_SET_STRING(exports, "rootDir", alt::ICore::Instance().GetRootDirectory()); - V8_OBJECT_SET_INT(exports, "defaultDimension", alt::DEFAULT_DIMENSION); - V8_OBJECT_SET_INT(exports, "globalDimension", alt::GLOBAL_DIMENSION); }); diff --git a/shared/bindings/BindingsMain.cpp b/shared/bindings/BindingsMain.cpp index 168e5f7b..a0bf4ca3 100644 --- a/shared/bindings/BindingsMain.cpp +++ b/shared/bindings/BindingsMain.cpp @@ -518,6 +518,9 @@ extern V8Module V8_OBJECT_SET_STRING(exports, "resourceName", V8ResourceImpl::GetResource(ctx)->GetName()); + V8_OBJECT_SET_INT(exports, "defaultDimension", alt::DEFAULT_DIMENSION); + V8_OBJECT_SET_INT(exports, "globalDimension", alt::GLOBAL_DIMENSION); + #ifdef ALT_CLIENT_API V8_OBJECT_SET_BOOLEAN(exports, "isClient", true); V8_OBJECT_SET_BOOLEAN(exports, "isServer", false); From ae4c17c9b2ca7d5b51275cb0784a1f329b31588c Mon Sep 17 00:00:00 2001 From: Vektor Date: Tue, 8 Aug 2023 23:32:50 +0200 Subject: [PATCH 02/10] fix audio output all getter --- client/src/bindings/AudioOutput.cpp | 6 ++---- shared/V8ResourceImpl.cpp | 11 +++++++++++ shared/V8ResourceImpl.h | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/client/src/bindings/AudioOutput.cpp b/client/src/bindings/AudioOutput.cpp index 30b11d49..da28133f 100644 --- a/client/src/bindings/AudioOutput.cpp +++ b/client/src/bindings/AudioOutput.cpp @@ -57,10 +57,8 @@ static void ConstructorAttached(const v8::FunctionCallbackInfo& info) static void AllAudioOutputGetter(v8::Local name, const v8::PropertyCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT_RESOURCE(); - auto objects = alt::ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::AUDIO_OUTPUT); - v8::Local jsArr = v8::Array::New(isolate, objects.size()); - for(size_t i = 0; i < objects.size(); ++i) jsArr->Set(ctx, i, resource->GetBaseObjectOrNull(objects[i])); - V8_RETURN(jsArr); + + V8_RETURN(resource->GetAllAudioOutputs()->Clone()); } static void AudioOutputCountGetter(v8::Local name, const v8::PropertyCallbackInfo& info) diff --git a/shared/V8ResourceImpl.cpp b/shared/V8ResourceImpl.cpp index 8c92e2db..4d42e7fc 100644 --- a/shared/V8ResourceImpl.cpp +++ b/shared/V8ResourceImpl.cpp @@ -313,6 +313,17 @@ v8::Local V8ResourceImpl::GetAllBlips() return jsAll; } +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])); + + jsAll->SetIntegrityLevel(GetContext(), v8::IntegrityLevel::kFrozen); + return jsAll; +} + v8::Local V8ResourceImpl::GetAllVirtualEntityGroups() { std::vector all = ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::VIRTUAL_ENTITY_GROUP); diff --git a/shared/V8ResourceImpl.h b/shared/V8ResourceImpl.h index 39096d2e..a382e9f4 100644 --- a/shared/V8ResourceImpl.h +++ b/shared/V8ResourceImpl.h @@ -244,6 +244,7 @@ class V8ResourceImpl : public alt::IResource::Impl v8::Local GetAllPlayers(); v8::Local GetAllVehicles(); v8::Local GetAllBlips(); + v8::Local GetAllAudioOutputs(); v8::Local GetAllCheckpoints(); v8::Local GetAllVirtualEntityGroups(); v8::Local GetAllVirtualEntities(); From bb3c1ffc43a09e6c05f2aea4e88e6a8073916b46 Mon Sep 17 00:00:00 2001 From: Blue Date: Sat, 12 Aug 2023 00:01:49 +0200 Subject: [PATCH 03/10] server: add clientDeleteObject & clientRequestObject --- server/src/events/Main.cpp | 26 +++++++++++++++++++++++++- shared/deps/cpp-sdk | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/server/src/events/Main.cpp b/server/src/events/Main.cpp index b4364d22..5bc20813 100644 --- a/server/src/events/Main.cpp +++ b/server/src/events/Main.cpp @@ -11,6 +11,8 @@ #include "cpp-sdk/events/CFireEvent.h" #include "cpp-sdk/events/CStartProjectileEvent.h" #include "cpp-sdk/events/CMetaDataChangeEvent.h" +#include "cpp-sdk/events/CClientDeleteObjectEvent.h" +#include "cpp-sdk/events/CClientRequestObjectEvent.h" using alt::CEvent; using EventType = CEvent::Type; @@ -197,7 +199,7 @@ V8_LOCAL_EVENT_HANDLER startSyncedScene(EventType::START_SYNCED_SCENE, const auto entityAndAnimHashPairs = ev->GetEntityAndAnimHashPairs(); const auto animHashArray = v8::Array::New(isolate, entityAndAnimHashPairs.size()); auto idx = 0; - for (auto [entity, animHash] : entityAndAnimHashPairs) + for(auto [entity, animHash] : entityAndAnimHashPairs) { V8_NEW_OBJECT(entityAnimPair) V8_OBJECT_SET_BASE_OBJECT(entityAnimPair, "entity", entity.get()) @@ -229,3 +231,25 @@ V8_LOCAL_EVENT_HANDLER updateSyncedScene(EventType::UPDATE_SYNCED_SCENE, args.push_back(V8Helpers::JSValue(ev->GetStartRate())); args.push_back(V8Helpers::JSValue(ev->GetSceneID())); }); + +V8_LOCAL_EVENT_HANDLER clientDeleteObject(EventType::CLIENT_DELETE_OBJECT_EVENT, + "clientDeleteObject", + [](V8ResourceImpl* resource, const CEvent* e, std::vector>& args) + { + auto ev = static_cast(e); + v8::Isolate* isolate = resource->GetIsolate(); + + args.push_back(resource->GetBaseObjectOrNull(ev->GetTarget())); + }); + +V8_LOCAL_EVENT_HANDLER clientRequestObject(EventType::CLIENT_REQUEST_OBJECT_EVENT, + "clientRequestObject", + [](V8ResourceImpl* resource, const CEvent* e, std::vector>& args) + { + auto ev = static_cast(e); + v8::Isolate* isolate = resource->GetIsolate(); + + args.push_back(resource->GetBaseObjectOrNull(ev->GetTarget())); + args.push_back(V8Helpers::JSValue(ev->GetName())); + args.push_back(resource->CreateVector3(ev->GetArgs())); + }); diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index 613fa008..06c718de 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit 613fa0084f925d8bea289211f819cc4934c265f9 +Subproject commit 06c718de66f58ebca7886d133058e44c37a12495 From a5a13462cbf5128f9d059b97bdafce05b7ad7e47 Mon Sep 17 00:00:00 2001 From: Blue Date: Sat, 12 Aug 2023 11:19:53 +0200 Subject: [PATCH 04/10] server: CClientRequestObjectEvent method changes --- server/src/events/Main.cpp | 4 ++-- shared/deps/cpp-sdk | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/events/Main.cpp b/server/src/events/Main.cpp index 5bc20813..c9474107 100644 --- a/server/src/events/Main.cpp +++ b/server/src/events/Main.cpp @@ -250,6 +250,6 @@ V8_LOCAL_EVENT_HANDLER clientRequestObject(EventType::CLIENT_REQUEST_OBJECT_EVEN v8::Isolate* isolate = resource->GetIsolate(); args.push_back(resource->GetBaseObjectOrNull(ev->GetTarget())); - args.push_back(V8Helpers::JSValue(ev->GetName())); - args.push_back(resource->CreateVector3(ev->GetArgs())); + args.push_back(V8Helpers::JSValue(ev->GetModel())); + args.push_back(resource->CreateVector3(ev->GetPosition())); }); diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index 06c718de..a8e78db1 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit 06c718de66f58ebca7886d133058e44c37a12495 +Subproject commit a8e78db18bcb071cf56758c332a68c5861582028 From da3fa75f802fd61dab2a7647a516f6f07306433c Mon Sep 17 00:00:00 2001 From: LeonMrBonnie Date: Sat, 13 May 2023 15:17:35 +0200 Subject: [PATCH 05/10] Revert "client: Bytecode changes" This reverts commit d07cd36177f9d7a50165998df953295bf14f9e85. --- client/src/IImportHandler.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/client/src/IImportHandler.cpp b/client/src/IImportHandler.cpp index 53409328..eed6d5f6 100644 --- a/client/src/IImportHandler.cpp +++ b/client/src/IImportHandler.cpp @@ -296,15 +296,27 @@ v8::MaybeLocal IImportHandler::ResolveBytecode(const std::string& na { v8::Isolate* isolate = v8::Isolate::GetCurrent(); + // Copy source code size + int sourceCodeSize = 0; + memcpy(&sourceCodeSize, buffer + sizeof(bytecodeMagic), sizeof(int)); // Copy bytecode buffer - size_t bytecodeSize = size - sizeof(bytecodeMagic); + size_t bytecodeSize = size - sizeof(bytecodeMagic) - sizeof(int); uint8_t* bytecode = new uint8_t[bytecodeSize]; - memcpy(bytecode, buffer + sizeof(bytecodeMagic), bytecodeSize); + memcpy(bytecode, buffer + sizeof(bytecodeMagic) + sizeof(int), bytecodeSize); v8::ScriptCompiler::CachedData* cachedData = new v8::ScriptCompiler::CachedData(bytecode, bytecodeSize, v8::ScriptCompiler::CachedData::BufferOwned); v8::ScriptOrigin origin(isolate, V8Helpers::JSValue(name), 0, 0, false, -1, v8::Local(), false, false, true, v8::Local()); - v8::ScriptCompiler::Source source{ V8Helpers::JSValue(" "), origin, cachedData }; + // Create source string + std::string sourceString; + sourceString.reserve(sourceCodeSize + 2); + sourceString += "'"; + for(size_t i = 0; i < sourceCodeSize; i++) + { + sourceString += "a"; + } + sourceString += "'"; + v8::ScriptCompiler::Source source{ V8Helpers::JSValue(sourceString), origin, cachedData }; v8::MaybeLocal module = v8::ScriptCompiler::CompileModule(isolate, &source, v8::ScriptCompiler::kConsumeCodeCache); if(cachedData->rejected) { From f53395e8ce1d85a403a88176a7e42a8e42dcf533 Mon Sep 17 00:00:00 2001 From: Vektor Date: Mon, 14 Aug 2023 09:46:02 +0200 Subject: [PATCH 06/10] update cpp sdk --- shared/deps/cpp-sdk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index a8e78db1..8d8e0cd9 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit a8e78db18bcb071cf56758c332a68c5861582028 +Subproject commit 8d8e0cd9b383883da3d767d632580decd09e3738 From f981d07bbc7cb8a5aad135878b269aa1c42cae4f Mon Sep 17 00:00:00 2001 From: Blue Date: Mon, 14 Aug 2023 10:31:28 +0200 Subject: [PATCH 07/10] 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; From 7b8231a3acb2aaaab0159bc3f7d5a0063d1eb234 Mon Sep 17 00:00:00 2001 From: Blue Date: Tue, 15 Aug 2023 11:18:41 +0200 Subject: [PATCH 08/10] shared: add isParachuting player getter --- client/src/bindings/Player.cpp | 1 + server/src/bindings/Player.cpp | 42 ++++++++++++++++++---------------- shared/deps/cpp-sdk | 2 +- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/client/src/bindings/Player.cpp b/client/src/bindings/Player.cpp index 1ffc7450..72bfbb74 100644 --- a/client/src/bindings/Player.cpp +++ b/client/src/bindings/Player.cpp @@ -210,6 +210,7 @@ extern V8Class v8Player("Player", V8Helpers::SetAccessor(isolate, tpl, "isOnLadder"); V8Helpers::SetAccessor(isolate, tpl, "isInMelee"); V8Helpers::SetAccessor(isolate, tpl, "isInCover"); + V8Helpers::SetAccessor(isolate, tpl, "isParachuting"); // V8Helpers::SetAccessor(isolate, tpl, "isSuperJumpEnabled"); // V8Helpers::SetAccessor(isolate, tpl, "isCrouching"); diff --git a/server/src/bindings/Player.cpp b/server/src/bindings/Player.cpp index 24b67768..c077c2e6 100644 --- a/server/src/bindings/Player.cpp +++ b/server/src/bindings/Player.cpp @@ -856,26 +856,27 @@ static void RequestCloudID(const v8::FunctionCallbackInfo& info) auto& persistent = promises.emplace_back(v8::Global(isolate, v8::Promise::Resolver::New(ctx).ToLocalChecked())); - player->RequestCloudID([&persistent, resource](bool ok, const std::string& result) { - resource->RunOnNextTick( - [=, &persistent, &resource]() - { - if(!resource->GetResource()->IsStarted()) - { - promises.remove(persistent); - return; - } - - auto isolate = resource->GetIsolate(); - auto context = resource->GetContext(); - - if (ok) - persistent.Get(isolate)->Resolve(context, V8Helpers::JSValue(result)); - else - persistent.Get(isolate)->Reject(context, v8::Exception::Error(V8Helpers::JSValue(result))); - promises.remove(persistent); - }); - }); + player->RequestCloudID( + [&persistent, resource](bool ok, const std::string& result) + { + resource->RunOnNextTick( + [=, &persistent, &resource]() + { + if(!resource->GetResource()->IsStarted()) + { + promises.remove(persistent); + return; + } + + auto isolate = resource->GetIsolate(); + auto context = resource->GetContext(); + + if(ok) persistent.Get(isolate)->Resolve(context, V8Helpers::JSValue(result)); + else + persistent.Get(isolate)->Reject(context, v8::Exception::Error(V8Helpers::JSValue(result))); + promises.remove(persistent); + }); + }); V8_RETURN(persistent.Get(isolate)->GetPromise()); } @@ -1437,6 +1438,7 @@ extern V8Class v8Player("Player", V8Helpers::SetAccessor(isolate, tpl, "isOnLadder"); V8Helpers::SetAccessor(isolate, tpl, "isInMelee"); V8Helpers::SetAccessor(isolate, tpl, "isInCover"); + V8Helpers::SetAccessor(isolate, tpl, "isParachuting"); V8Helpers::SetAccessor(isolate, tpl, "currentAnimationDict"); V8Helpers::SetAccessor(isolate, tpl, "currentAnimationName"); diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index 8d8e0cd9..d31984df 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit 8d8e0cd9b383883da3d767d632580decd09e3738 +Subproject commit d31984dfb3ef053a3a4c3ed10411e17a268fcbf8 From b8e591192126fa303fa8bfb3c219c2a3967fd953 Mon Sep 17 00:00:00 2001 From: Blue Date: Sun, 20 Aug 2023 19:54:34 +0200 Subject: [PATCH 09/10] Update sdk --- shared/deps/cpp-sdk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index d31984df..d7aed4c1 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit d31984dfb3ef053a3a4c3ed10411e17a268fcbf8 +Subproject commit d7aed4c1639b10c438d78d9697379693a2b8c74e From 9df6cd527bd47a849fb5e08e38a4870df39e618e Mon Sep 17 00:00:00 2001 From: Artem Dzhemesiuk Date: Sun, 20 Aug 2023 20:55:05 +0200 Subject: [PATCH 10/10] SDK update --- client/src/IImportHandler.cpp | 2 +- client/src/bindings/HttpClient.cpp | 40 ++++++++++++------------- client/src/bindings/WebSocketClient.cpp | 4 +-- shared/helpers/Serialization.cpp | 4 +-- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/client/src/IImportHandler.cpp b/client/src/IImportHandler.cpp index eed6d5f6..82451f7f 100644 --- a/client/src/IImportHandler.cpp +++ b/client/src/IImportHandler.cpp @@ -89,7 +89,7 @@ std::deque IImportHandler::GetModuleKeys(const std::string& name) std::deque keys; alt::MValueDict _exports = resource->GetExports(); - for(auto it = _exports->Begin(); it; it = _exports->Next()) keys.push_back(it->GetKey()); + for(auto it = _exports->Begin(); it != _exports->End(); ++it) keys.push_back(it->first); return keys; } diff --git a/client/src/bindings/HttpClient.cpp b/client/src/bindings/HttpClient.cpp index a3549225..d95a9528 100644 --- a/client/src/bindings/HttpClient.cpp +++ b/client/src/bindings/HttpClient.cpp @@ -23,9 +23,9 @@ static void GetExtraHeaders(const v8::FunctionCallbackInfo& info) auto dict = client->GetExtraHeaders(); V8_NEW_OBJECT(headers); - for(auto it = dict->Begin(); it; it = dict->Next()) + for(auto it = dict->Begin(); it != dict->End(); ++it) { - headers->Set(ctx, V8Helpers::JSValue(it->GetKey().c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->GetValue())->Value().c_str())); + headers->Set(ctx, V8Helpers::JSValue(it->first.c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->second)->Value().c_str())); } V8_RETURN(headers); @@ -69,9 +69,9 @@ static void Get(const v8::FunctionCallbackInfo& info) V8_OBJECT_SET_INT(responseObj, "statusCode", response.statusCode); V8_OBJECT_SET_STRING(responseObj, "body", response.body); V8_NEW_OBJECT(headers); - for(auto it = response.headers->Begin(); it; it = response.headers->Next()) + for(auto it = response.headers->Begin(); it != response.headers->End(); ++it) { - headers->Set(ctx, V8Helpers::JSValue(it->GetKey().c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->GetValue())->Value().c_str())); + headers->Set(ctx, V8Helpers::JSValue(it->first.c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->second)->Value().c_str())); } responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers); resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj); @@ -112,9 +112,9 @@ static void Head(const v8::FunctionCallbackInfo& info) V8_OBJECT_SET_INT(responseObj, "statusCode", response.statusCode); V8_OBJECT_SET_STRING(responseObj, "body", response.body); V8_NEW_OBJECT(headers); - for(auto it = response.headers->Begin(); it; it = response.headers->Next()) + for(auto it = response.headers->Begin(); it != response.headers->End(); ++it) { - headers->Set(ctx, V8Helpers::JSValue(it->GetKey().c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->GetValue())->Value().c_str())); + headers->Set(ctx, V8Helpers::JSValue(it->first.c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->second)->Value().c_str())); } responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers); resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj); @@ -156,9 +156,9 @@ static void Post(const v8::FunctionCallbackInfo& info) V8_OBJECT_SET_INT(responseObj, "statusCode", response.statusCode); V8_OBJECT_SET_STRING(responseObj, "body", response.body); V8_NEW_OBJECT(headers); - for(auto it = response.headers->Begin(); it; it = response.headers->Next()) + for(auto it = response.headers->Begin(); it != response.headers->End(); ++it) { - headers->Set(ctx, V8Helpers::JSValue(it->GetKey().c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->GetValue())->Value().c_str())); + headers->Set(ctx, V8Helpers::JSValue(it->first.c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->second)->Value().c_str())); } responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers); resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj); @@ -200,9 +200,9 @@ static void Put(const v8::FunctionCallbackInfo& info) V8_OBJECT_SET_INT(responseObj, "statusCode", response.statusCode); V8_OBJECT_SET_STRING(responseObj, "body", response.body); V8_NEW_OBJECT(headers); - for(auto it = response.headers->Begin(); it; it = response.headers->Next()) + for(auto it = response.headers->Begin(); it != response.headers->End(); ++it) { - headers->Set(ctx, V8Helpers::JSValue(it->GetKey().c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->GetValue())->Value().c_str())); + headers->Set(ctx, V8Helpers::JSValue(it->first.c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->second)->Value().c_str())); } responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers); resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj); @@ -244,9 +244,9 @@ static void Delete(const v8::FunctionCallbackInfo& info) V8_OBJECT_SET_INT(responseObj, "statusCode", response.statusCode); V8_OBJECT_SET_STRING(responseObj, "body", response.body); V8_NEW_OBJECT(headers); - for(auto it = response.headers->Begin(); it; it = response.headers->Next()) + for(auto it = response.headers->Begin(); it != response.headers->End(); ++it) { - headers->Set(ctx, V8Helpers::JSValue(it->GetKey().c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->GetValue())->Value().c_str())); + headers->Set(ctx, V8Helpers::JSValue(it->first.c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->second)->Value().c_str())); } responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers); resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj); @@ -288,9 +288,9 @@ static void Connect(const v8::FunctionCallbackInfo& info) V8_OBJECT_SET_INT(responseObj, "statusCode", response.statusCode); V8_OBJECT_SET_STRING(responseObj, "body", response.body); V8_NEW_OBJECT(headers); - for(auto it = response.headers->Begin(); it; it = response.headers->Next()) + for(auto it = response.headers->Begin(); it != response.headers->End(); ++it) { - headers->Set(ctx, V8Helpers::JSValue(it->GetKey().c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->GetValue())->Value().c_str())); + headers->Set(ctx, V8Helpers::JSValue(it->first.c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->second)->Value().c_str())); } responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers); resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj); @@ -332,9 +332,9 @@ static void Options(const v8::FunctionCallbackInfo& info) V8_OBJECT_SET_INT(responseObj, "statusCode", response.statusCode); V8_OBJECT_SET_STRING(responseObj, "body", response.body); V8_NEW_OBJECT(headers); - for(auto it = response.headers->Begin(); it; it = response.headers->Next()) + for(auto it = response.headers->Begin(); it != response.headers->End(); ++it) { - headers->Set(ctx, V8Helpers::JSValue(it->GetKey().c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->GetValue())->Value().c_str())); + headers->Set(ctx, V8Helpers::JSValue(it->first.c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->second)->Value().c_str())); } responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers); resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj); @@ -376,9 +376,9 @@ static void Trace(const v8::FunctionCallbackInfo& info) V8_OBJECT_SET_INT(responseObj, "statusCode", response.statusCode); V8_OBJECT_SET_STRING(responseObj, "body", response.body); V8_NEW_OBJECT(headers); - for(auto it = response.headers->Begin(); it; it = response.headers->Next()) + for(auto it = response.headers->Begin(); it != response.headers->End(); ++it) { - headers->Set(ctx, V8Helpers::JSValue(it->GetKey().c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->GetValue())->Value().c_str())); + headers->Set(ctx, V8Helpers::JSValue(it->first.c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->second)->Value().c_str())); } responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers); resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj); @@ -420,9 +420,9 @@ static void Patch(const v8::FunctionCallbackInfo& info) V8_OBJECT_SET_INT(responseObj, "statusCode", response.statusCode); V8_OBJECT_SET_STRING(responseObj, "body", response.body); V8_NEW_OBJECT(headers); - for(auto it = response.headers->Begin(); it; it = response.headers->Next()) + for(auto it = response.headers->Begin(); it != response.headers->End(); ++it) { - headers->Set(ctx, V8Helpers::JSValue(it->GetKey().c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->GetValue())->Value().c_str())); + headers->Set(ctx, V8Helpers::JSValue(it->first.c_str()), V8Helpers::JSValue(std::dynamic_pointer_cast(it->second)->Value().c_str())); } responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers); resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj); diff --git a/client/src/bindings/WebSocketClient.cpp b/client/src/bindings/WebSocketClient.cpp index 17c5e5ec..9ccd2a33 100644 --- a/client/src/bindings/WebSocketClient.cpp +++ b/client/src/bindings/WebSocketClient.cpp @@ -131,9 +131,9 @@ static void GetExtraHeaders(const v8::FunctionCallbackInfo& info) auto extraHeaders = webSocket->GetExtraHeaders(); V8_NEW_OBJECT(headersObject); - for(auto it = extraHeaders->Begin(); it; it = extraHeaders->Next()) + for(auto it = extraHeaders->Begin(); it != extraHeaders->End(); ++it) { - std::string key = it->GetKey(); + std::string key = it->first; V8_OBJECT_SET_STRING(headersObject, key.c_str(), std::dynamic_pointer_cast(extraHeaders->Get(key))->Value()); } diff --git a/shared/helpers/Serialization.cpp b/shared/helpers/Serialization.cpp index 52666e5b..0af0ca34 100644 --- a/shared/helpers/Serialization.cpp +++ b/shared/helpers/Serialization.cpp @@ -210,9 +210,9 @@ v8::Local V8Helpers::MValueToV8(alt::MValueConst val) alt::MValueDictConst dict = std::dynamic_pointer_cast(val); v8::Local v8Obj = v8::Object::New(isolate); - for(auto it = dict->Begin(); it; it = dict->Next()) + for(auto it = dict->Begin(); it != dict->End(); ++it) { - v8Obj->Set(ctx, V8Helpers::JSValue(it->GetKey()), MValueToV8(it->GetValue())); + v8Obj->Set(ctx, V8Helpers::JSValue(it->first), MValueToV8(it->second)); } return v8Obj;