MCPcopy
hub / github.com/socketio/socket.io / use

Method use

packages/socket.io/lib/index.ts:864–872  ·  packages/socket.io/lib/index.ts::Server.use

* Registers a middleware, which is a function that gets executed for every incoming {@link Socket}. * * @example * io.use((socket, next) => { * // ... * next(); * }); * * @param fn - the middleware function

(
    fn: (
      socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>,
      next: (err?: ExtendedError) => void,
    ) => void,
  )

Source from the content-addressed store, hash-verified

862 * @param fn - the middleware function
863 */
864 public use(
865 fn: (
866 socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>,
867 next: (err?: ExtendedError) => void,
868 ) => void,
869 ): this {
870 this.sockets.use(fn);
871 return this;
872 }
873
874 /**
875 * Targets a room when emitting.

Callers 15

createServerFunction · 0.95
beforeAllFunction · 0.45
server.jsFile · 0.45
constructorFunction · 0.45
webtransport.mjsFile · 0.45
middlewares.jsFile · 0.45
index.jsFile · 0.45
socket.tsFile · 0.45
middleware.tsFile · 0.45
uws.tsFile · 0.45
namespaces.tsFile · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected