linkdave 0.2.0-dev.67c58c7 → 0.2.0-dev.db8ab4a
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/dist/client.js +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +8 -9
- package/dist/types.d.ts +0 -1
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -63,8 +63,8 @@ export class LinkDaveClient extends EventEmitter {
|
|
|
63
63
|
if (!node.connected || node.draining) {
|
|
64
64
|
continue;
|
|
65
65
|
}
|
|
66
|
-
if (node.
|
|
67
|
-
lowestCount = node.
|
|
66
|
+
if (node.stats.players < lowestCount) {
|
|
67
|
+
lowestCount = node.stats.players;
|
|
68
68
|
bestNode = node;
|
|
69
69
|
}
|
|
70
70
|
}
|
package/dist/node.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
2
|
import { RESTClient } from "./rest.js";
|
|
3
|
-
import type { Events, PlayPayload, SeekPayload, VoiceUpdatePayload } from "./types.js";
|
|
3
|
+
import type { Events, PlayPayload, SeekPayload, StatsPayload, VoiceUpdatePayload } from "./types.js";
|
|
4
4
|
export interface NodeOptions {
|
|
5
5
|
name: string;
|
|
6
6
|
url: string;
|
|
@@ -31,7 +31,7 @@ export declare class Node extends EventEmitter {
|
|
|
31
31
|
disconnect(): void;
|
|
32
32
|
get state(): NodeState;
|
|
33
33
|
get sessionId(): string | null;
|
|
34
|
-
get
|
|
34
|
+
get stats(): StatsPayload;
|
|
35
35
|
get draining(): boolean;
|
|
36
36
|
get connected(): boolean;
|
|
37
37
|
incrementPlayerCount(): void;
|
package/dist/node.js
CHANGED
|
@@ -20,7 +20,7 @@ export class Node extends EventEmitter {
|
|
|
20
20
|
#reconnectAttempts = 0;
|
|
21
21
|
#reconnectTimeout = null;
|
|
22
22
|
#state = NodeState.Disconnected;
|
|
23
|
-
#
|
|
23
|
+
#stats = { players: 0, playing_tracks: 0, uptime: 0, memory: 0 };
|
|
24
24
|
constructor(options) {
|
|
25
25
|
super();
|
|
26
26
|
this.name = options.name;
|
|
@@ -80,8 +80,8 @@ export class Node extends EventEmitter {
|
|
|
80
80
|
get sessionId() {
|
|
81
81
|
return this.#sessionId;
|
|
82
82
|
}
|
|
83
|
-
get
|
|
84
|
-
return this.#
|
|
83
|
+
get stats() {
|
|
84
|
+
return this.#stats;
|
|
85
85
|
}
|
|
86
86
|
get draining() {
|
|
87
87
|
return this.state === NodeState.Draining;
|
|
@@ -90,12 +90,12 @@ export class Node extends EventEmitter {
|
|
|
90
90
|
return this.#state === NodeState.Connected || this.#state === NodeState.Draining;
|
|
91
91
|
}
|
|
92
92
|
incrementPlayerCount() {
|
|
93
|
-
this.#
|
|
93
|
+
this.#stats.players++;
|
|
94
94
|
}
|
|
95
95
|
decrementPlayerCount() {
|
|
96
|
-
if (this.#
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
if (this.#stats.players <= 0)
|
|
97
|
+
return;
|
|
98
|
+
this.#stats.players--;
|
|
99
99
|
}
|
|
100
100
|
#onMessage(event) {
|
|
101
101
|
try {
|
|
@@ -131,8 +131,7 @@ export class Node extends EventEmitter {
|
|
|
131
131
|
this.emit(EventName.VoiceDisconnect, message.d);
|
|
132
132
|
break;
|
|
133
133
|
case ServerOpCodes.Stats:
|
|
134
|
-
this.#
|
|
135
|
-
this.#state = message.d.draining ? NodeState.Draining : NodeState.Connected;
|
|
134
|
+
this.#stats = message.d;
|
|
136
135
|
this.emit(EventName.Stats, message.d);
|
|
137
136
|
break;
|
|
138
137
|
case ServerOpCodes.NodeDraining:
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED