@nativewrappers/common 0.0.59 → 0.0.60
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/net/NetworkedMap.d.ts +1 -0
- package/net/NetworkedMap.js +6 -6
- package/package.json +1 -1
package/net/NetworkedMap.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare class NetworkedMap<K, V> extends Map<K, V> {
|
|
|
11
11
|
addSubscriber(source: number): void;
|
|
12
12
|
removeSubscriber(sub: number): boolean;
|
|
13
13
|
hasSubscriber(sub: number): boolean;
|
|
14
|
+
subscriberCount(): number;
|
|
14
15
|
private handleSync;
|
|
15
16
|
listenForChange(key: K, fn: ChangeListener<V>): void;
|
|
16
17
|
set(key: K, value: V): this;
|
package/net/NetworkedMap.js
CHANGED
|
@@ -15,13 +15,13 @@ var MapChangeType;
|
|
|
15
15
|
// Used to not make a bunch of on/raw events, we just reuse the same one and look up the data in the map
|
|
16
16
|
class NetworkedMapEventManager {
|
|
17
17
|
#syncedCalls = new Map();
|
|
18
|
-
#playerDropped = new Map();
|
|
19
18
|
constructor() {
|
|
20
19
|
SERVER: if (GlobalData.IS_SERVER) {
|
|
21
20
|
on("playerDropped", () => {
|
|
21
|
+
const src = source;
|
|
22
22
|
// call the player dropped for each call
|
|
23
|
-
for (const [_k,
|
|
24
|
-
|
|
23
|
+
for (const [_k, map] of this.#syncedCalls) {
|
|
24
|
+
map.removeSubscriber(src);
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
return;
|
|
@@ -45,12 +45,9 @@ class NetworkedMapEventManager {
|
|
|
45
45
|
// abuse typescript, we don't want the end user to use these calls but we still want it to be accessible internally.
|
|
46
46
|
// @ts-ignore
|
|
47
47
|
this.#syncedCalls.set(map.SyncName, map);
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
this.#playerDropped.set(map.SyncName, map.onPlayerDropped);
|
|
50
48
|
}
|
|
51
49
|
removeNetworkedMap(syncName) {
|
|
52
50
|
this.#syncedCalls.delete(syncName);
|
|
53
|
-
this.#playerDropped.delete(syncName);
|
|
54
51
|
}
|
|
55
52
|
}
|
|
56
53
|
const netManager = new NetworkedMapEventManager();
|
|
@@ -110,6 +107,9 @@ export class NetworkedMap extends Map {
|
|
|
110
107
|
hasSubscriber(sub) {
|
|
111
108
|
return this.#subscribers.has(sub);
|
|
112
109
|
}
|
|
110
|
+
subscriberCount() {
|
|
111
|
+
return this.#subscribers.size;
|
|
112
|
+
}
|
|
113
113
|
handleSync(data) {
|
|
114
114
|
for (const [change_type, key, value, possibly_undefined_subvalue] of data) {
|
|
115
115
|
switch (change_type) {
|