-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Closed
Labels
questionFurther information is requestedFurther information is requested
Milestone
Description
Describe the bug
I am trying to retrieve a socket instance by its id, however, using the io.fetchSockets()
method always returns a RemoteSocket[]
, so methods like socket.timeout
can't be used from the resulting instance. According to the docs fetchSockets
should return Socket[] | RemoteSocket[]
. I am not using an adapter and the behavior is the same in main namespace.
To Reproduce
Please fill the following code example:
Socket.IO server version: 4.5.4
Server
//Returns a Promise<RemoteSocket | undefined>
const socketInstanceById = async (socketId: string) => {
const sockets = await io.in(socketId).fetchSockets();
for (const socket of sockets) {
if (socket.id === socketId) return socket;
}
}
Reducing the example to
const sockets = await io.fetchSockets()
//Type of `sockets` is RemoteSocket[]
Is fetchSockets
the only way to retrieve a socket instance by its id? If so is there a way to get a Socket instance and not a RemoteSocket?
Expected behavior
fetchSockets
should return normal socket instances when called on the same server.
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested