yolkbot 0.1.1-alpha.36 → 0.1.1-alpha.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/build/global.js +1 -1
- package/browser/build/module.js +1 -1
- package/package.json +1 -1
- package/src/api.js +6 -1
- package/src/bot.js +7 -2
- package/src/matchmaker.js +7 -0
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -13,6 +13,11 @@ const queryServices = async (request, proxy = '', instance = 'shellshock.io') =>
|
|
|
13
13
|
const attempt = async () => {
|
|
14
14
|
try {
|
|
15
15
|
ws = new yolkws(`wss://${instance}/services/`, proxy);
|
|
16
|
+
ws.onerror = async (e) => {
|
|
17
|
+
console.error(e);
|
|
18
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
19
|
+
return await attempt();
|
|
20
|
+
}
|
|
16
21
|
} catch {
|
|
17
22
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
18
23
|
await attempt();
|
|
@@ -23,7 +28,7 @@ const queryServices = async (request, proxy = '', instance = 'shellshock.io') =>
|
|
|
23
28
|
|
|
24
29
|
return new Promise((resolve) => {
|
|
25
30
|
ws.onopen = () => {
|
|
26
|
-
|
|
31
|
+
ws.onerror = null;
|
|
27
32
|
ws.send(JSON.stringify(request));
|
|
28
33
|
}
|
|
29
34
|
|
package/src/bot.js
CHANGED
|
@@ -548,6 +548,11 @@ export class Bot {
|
|
|
548
548
|
const attempt = async () => {
|
|
549
549
|
try {
|
|
550
550
|
this.game.socket = new yolkws(`wss://${this.game.raw.subdomain}.${this.instance}/game/${this.game.raw.id}`, this.proxy);
|
|
551
|
+
this.game.socket.onerror = async (e) => {
|
|
552
|
+
console.error(e);
|
|
553
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
554
|
+
return await attempt();
|
|
555
|
+
}
|
|
551
556
|
} catch {
|
|
552
557
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
553
558
|
await attempt();
|
|
@@ -559,7 +564,7 @@ export class Bot {
|
|
|
559
564
|
this.game.socket.binaryType = 'arraybuffer';
|
|
560
565
|
|
|
561
566
|
this.game.socket.onopen = () => {
|
|
562
|
-
|
|
567
|
+
this.game.socket.onerror = null;
|
|
563
568
|
}
|
|
564
569
|
|
|
565
570
|
this.game.socket.onmessage = this.#onGameMesssage.bind(this);
|
|
@@ -1909,7 +1914,7 @@ export class Bot {
|
|
|
1909
1914
|
|
|
1910
1915
|
clearInterval(this.updateIntervalId);
|
|
1911
1916
|
|
|
1912
|
-
this.game.socket.close();
|
|
1917
|
+
if (this.game) this.game.socket.close();
|
|
1913
1918
|
this.matchmaker.close();
|
|
1914
1919
|
|
|
1915
1920
|
if (!finishDispatches) this._dispatches = [];
|
package/src/matchmaker.js
CHANGED
|
@@ -34,6 +34,11 @@ export class Matchmaker {
|
|
|
34
34
|
const attempt = async () => {
|
|
35
35
|
try {
|
|
36
36
|
this.ws = new yolkws(`wss://${instance}/matchmaker/`, this.proxy);
|
|
37
|
+
this.ws.onerror = async (e) => {
|
|
38
|
+
console.error(e);
|
|
39
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
40
|
+
return await attempt();
|
|
41
|
+
}
|
|
37
42
|
} catch {
|
|
38
43
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
39
44
|
await attempt();
|
|
@@ -44,6 +49,8 @@ export class Matchmaker {
|
|
|
44
49
|
|
|
45
50
|
this.ws.onopen = () => {
|
|
46
51
|
this.connected = true;
|
|
52
|
+
this.ws.onerror = null;
|
|
53
|
+
|
|
47
54
|
if (this.sessionId) {
|
|
48
55
|
this.onceConnected.forEach(func => func());
|
|
49
56
|
}
|