Skip to content

Commit 348b438

Browse files
Add ipv6 support for networking entity
1 parent c58c6d8 commit 348b438

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

api/AltV.Net.NetworkingEntity/Client/networking-entity.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,21 @@ import "./deps/reconnecting-websocket.min.js";
44
class NetworkingEntity {
55
constructor() {
66
alt.on("entitySetup", (url, token) => {
7-
this.websocket = new WebSocket(url, token);
7+
const protocolSplit = url.split("//");
8+
const protocol = protocolSplit[0] + "//";
9+
const splitUrl = protocolSplit[1].split(":");
10+
if (splitUrl.length > 2) {
11+
let address = "";
12+
for (let i = 0; i < splitUrl.length - 1; i++) {
13+
address += splitUrl[i];
14+
if (i < splitUrl.length - 2) {
15+
address += ":";
16+
}
17+
}
18+
this.websocket = new WebSocket(protocol + "[" + address + "]:" + splitUrl[splitUrl.length - 1], token);
19+
} else {
20+
this.websocket = new WebSocket(url, token);
21+
}
822
});
923

1024
alt.on("entityDestroy", () => {

0 commit comments

Comments
 (0)