redweb 0.7.1 → 0.7.2
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/index.d.ts +15 -14
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -113,26 +113,27 @@ declare module 'redweb' {
|
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
/** Generic event‑driven registry for socket objects */
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
onCreate?: (client: T) => boolean | void;
|
|
120
|
-
onRemove?: (client: T) => boolean | void;
|
|
116
|
+
/** Generic event-driven registry for socket objects */
|
|
117
|
+
export class SocketRegistry<T extends SocketWrapper = SocketWrapper> extends EventEmitter {
|
|
118
|
+
protected items: T[];
|
|
121
119
|
|
|
122
120
|
constructor();
|
|
123
121
|
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
/** Adds a socket-bound object to the registry */
|
|
123
|
+
add(item: T): void;
|
|
126
124
|
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Removes a socket-bound object by reference or id (default key: 'id')
|
|
127
|
+
* @param itemOrId Object or ID string
|
|
128
|
+
* @param by Key name to match against (default is 'id')
|
|
129
|
+
*/
|
|
130
|
+
remove(itemOrId: T | string, by?: keyof T): boolean;
|
|
129
131
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
allWithout(socket: WebSocket): T[];
|
|
132
|
+
/** Returns a shallow copy of all registered items */
|
|
133
|
+
all(): T[];
|
|
133
134
|
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
/** Returns the number of registered items */
|
|
136
|
+
count(): number;
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
/** ─────────────────── CONCRETE SERVERS ─────────────────── */
|