@@ -177,7 +177,9 @@ export class BroadcastOperator<EmitEvents extends EventsMap>
177
177
*
178
178
* @public
179
179
*/
180
- public fetchSockets ( ) : Promise < RemoteSocket < EmitEvents > [ ] > {
180
+ public fetchSockets < SocketData = any > ( ) : Promise <
181
+ RemoteSocket < EmitEvents , SocketData > [ ]
182
+ > {
181
183
return this . adapter
182
184
. fetchSockets ( {
183
185
rooms : this . rooms ,
@@ -187,9 +189,12 @@ export class BroadcastOperator<EmitEvents extends EventsMap>
187
189
return sockets . map ( ( socket ) => {
188
190
if ( socket instanceof Socket ) {
189
191
// FIXME the TypeScript compiler complains about missing private properties
190
- return socket as unknown as RemoteSocket < EmitEvents > ;
192
+ return socket as unknown as RemoteSocket < EmitEvents , SocketData > ;
191
193
} else {
192
- return new RemoteSocket ( this . adapter , socket as SocketDetails ) ;
194
+ return new RemoteSocket (
195
+ this . adapter ,
196
+ socket as SocketDetails < SocketData >
197
+ ) ;
193
198
}
194
199
} ) ;
195
200
} ) ;
@@ -247,27 +252,27 @@ export class BroadcastOperator<EmitEvents extends EventsMap>
247
252
/**
248
253
* Format of the data when the Socket instance exists on another Socket.IO server
249
254
*/
250
- interface SocketDetails {
255
+ interface SocketDetails < SocketData > {
251
256
id : SocketId ;
252
257
handshake : Handshake ;
253
258
rooms : Room [ ] ;
254
- data : any ;
259
+ data : SocketData ;
255
260
}
256
261
257
262
/**
258
263
* Expose of subset of the attributes and methods of the Socket class
259
264
*/
260
- export class RemoteSocket < EmitEvents extends EventsMap >
265
+ export class RemoteSocket < EmitEvents extends EventsMap , SocketData >
261
266
implements TypedEventBroadcaster < EmitEvents >
262
267
{
263
268
public readonly id : SocketId ;
264
269
public readonly handshake : Handshake ;
265
270
public readonly rooms : Set < Room > ;
266
- public readonly data : any ;
271
+ public readonly data : SocketData ;
267
272
268
273
private readonly operator : BroadcastOperator < EmitEvents > ;
269
274
270
- constructor ( adapter : Adapter , details : SocketDetails ) {
275
+ constructor ( adapter : Adapter , details : SocketDetails < SocketData > ) {
271
276
this . id = details . id ;
272
277
this . handshake = details . handshake ;
273
278
this . rooms = new Set ( details . rooms ) ;
0 commit comments