Skip to content

Commit

Permalink
fix(client): Add HttpClientFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
xLuxy committed Mar 18, 2024
1 parent abddd69 commit 576732a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions client/js/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ addAllGetter(alt.AudioOutputFrontend, alt.Enums.BaseObjectType.AUDIO_OUTPUT_FRON
addAllGetter(alt.AudioOutputWorld, alt.Enums.BaseObjectType.AUDIO_OUTPUT_WORLD);
addAllGetter(alt.RmlDocument, alt.Enums.BaseObjectType.RML_DOCUMENT);
addAllGetter(alt.TextLabel, alt.Enums.BaseObjectType.TEXT_LABEL);
addAllGetter(alt.HttpClient, alt.Enums.BaseObjectType.HTTP_CLIENT);
addAllGetter(alt.WebSocketClient, alt.Enums.BaseObjectType.WEBSOCKET_CLIENT);
addAllGetter(alt.WebView, alt.Enums.BaseObjectType.WEBVIEW);

Expand Down
1 change: 1 addition & 0 deletions client/js/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ registerFactory(alt.LocalObject, alt.Enums.BaseObjectType.LOCAL_OBJECT);

registerFactory(alt.RmlDocument, alt.Enums.BaseObjectType.RML_DOCUMENT);

registerFactory(alt.HttpClient, alt.Enums.BaseObjectType.HTTP_CLIENT);
registerFactory(alt.WebSocketClient, alt.Enums.BaseObjectType.WEBSOCKET_CLIENT);

registerFactory(alt.WebView, alt.Enums.BaseObjectType.WEBVIEW);
Expand Down
6 changes: 6 additions & 0 deletions client/src/factories/HttpClientFactory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "FactoryHandler.h"

// clang-format off
static js::FactoryHandler httpClientFactory(alt::IBaseObject::Type::HTTP_CLIENT, [](js::Object& args) -> alt::IBaseObject* {
return alt::ICore::Instance().CreateHttpClient();
});
2 changes: 2 additions & 0 deletions types/client/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ declare module "@altv/client" {

readonly extraHeaders: Record<string, string>;

static create(): HttpClient;

static getByID(id: number): HttpClient | null;
}

Expand Down
2 changes: 1 addition & 1 deletion types/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@altv/client",
"version": "0.0.30",
"version": "0.0.31",
"description": "This package contains the type definitions for the alt:V JS module v2 client types",
"types": "index.d.ts",
"files": [
Expand Down

0 comments on commit 576732a

Please sign in to comment.