Skip to content

Commit

Permalink
feat(server): minor version in events
Browse files Browse the repository at this point in the history
  • Loading branch information
vadzz-dev committed Dec 28, 2023
1 parent 933f76c commit 7b6f192
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
20 changes: 19 additions & 1 deletion server/src/bindings/ConnectionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,26 @@ static void BranchGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v
}

static void BuildGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_DEPRECATE("ConnectionInfo build", "versionMajor & versionMinor");

V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_GET_THIS_BASE_OBJECT(con, alt::IConnectionInfo);
V8_RETURN_UINT(con->GetVersionMajor());
}

static void VersionMajorGetter(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_UINT(con->GetVersionMajor());
}

static void VersionMinorGetter(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_UINT(con->GetBuild());
V8_RETURN_UINT(con->GetVersionMinor());
}

static void CdnUrlGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
Expand Down Expand Up @@ -216,6 +232,8 @@ extern V8Class v8ConnectionInfo("ConnectionInfo",
V8Helpers::SetAccessor(isolate, tpl, "isDebug", &IsDebugGetter);
V8Helpers::SetAccessor(isolate, tpl, "branch", &BranchGetter);
V8Helpers::SetAccessor(isolate, tpl, "build", &BuildGetter);
V8Helpers::SetAccessor(isolate, tpl, "versionMajor", &VersionMajorGetter);
V8Helpers::SetAccessor(isolate, tpl, "versionMinor", &VersionMinorGetter);
V8Helpers::SetAccessor(isolate, tpl, "cdnUrl", &CdnUrlGetter);
V8Helpers::SetAccessor(isolate, tpl, "passwordHash", &PasswordHashGetter);
V8Helpers::SetAccessor(isolate, tpl, "ip", &IpGetter);
Expand Down
3 changes: 2 additions & 1 deletion server/src/events/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ V8Helpers::LocalEventHandler playerConnectDenied(EventType::PLAYER_CONNECT_DENIE
args.push_back(V8Helpers::JSValue(ev->GetPasswordHash()));
args.push_back(V8Helpers::JSValue(ev->IsDebug()));
args.push_back(V8Helpers::JSValue(ev->GetBranch()));
args.push_back(V8Helpers::JSValue(ev->GetMajorVersion()));
args.push_back(V8Helpers::JSValue(ev->GetVersionMajor()));
// TODO: no idea where to put version minor to not break backward compatibility, not sure it's needed at all
args.push_back(V8Helpers::JSValue(ev->GetCdnUrl()));
args.push_back(V8Helpers::JSValue(ev->GetDiscordId()));
});
Expand Down
2 changes: 1 addition & 1 deletion shared/deps/cpp-sdk

0 comments on commit 7b6f192

Please sign in to comment.