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

Method use

packages/socket.io/lib/namespace.ts:219–227  ·  view source on GitHub ↗

* Registers a middleware, which is a function that gets executed for every incoming {@link Socket}. * * @example * const myNamespace = io.of("/my-namespace"); * * myNamespace.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

217 * @param fn - the middleware function
218 */
219 public use(
220 fn: (
221 socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>,
222 next: (err?: ExtendedError) => void,
223 ) => void,
224 ): this {
225 this._fns.push(fn);
226 return this;
227 }
228
229 /**
230 * Executes the middleware for an incoming client.

Callers 1

createChildMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected