Broadcast Decorator

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

Overview

function Broadcast(eventName: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) =>; void;

Description

Broadcast the response for all client registered in the same namespace.

With the @Broadcast decorator, the method will accept a return type (Promise or not).

Example

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

  @Input("event")
  @Broadcast("returnEvent")
  async myMethod(@Args(0) data: any, @Nsp socket): Promise<any> {
     return Promise.resolve({data})
  }
}