Nsp Decorator

Module
import { Nsp } from "@tsed/socketio"
Source/packages/socketio/src/decorators/nsp.ts

Overview

function Nsp(target: any, propertyKey?: string, index?: number): any;

Description

Inject the SocketIO.Namespace instance in the decorated parameter.

Example

@SocketService("/nsp")
export class MyWS {

  @Nsp
  nsp: SocketIO.Namespace; // will inject SocketIO.Namespace (not available on constructor)

  @Nsp("/my-other-namespace")
  nspOther: SocketIO.Namespace; // communication between two namespace

  @Input("event")
  myMethod(@Nsp namespace: SocketIO.Namespace) {

  }
}