Leaf
    Preparing search index...

    Class RemoteSocket<EmitEvents, SocketData>

    Expose of subset of the attributes and methods of the Socket class

    Type Parameters

    • EmitEvents extends EventsMap
    • SocketData

    Implements

    Index

    Constructors

    Properties

    handshake: Handshake
    id: string
    rooms: Set<string>

    Methods

    • Disconnects this client.

      Parameters

      • Optionalclose: boolean

        if true, closes the underlying connection

      Returns this

      self

    • Type Parameters

      • Ev extends string | symbol

      Parameters

      Returns boolean

    • Joins a room.

      Parameters

      • room: string | string[]

        room or array of rooms

      Returns void

    • Leaves a room.

      Parameters

      • room: string

      Returns void

    • Adds a timeout in milliseconds for the next operation.

      Parameters

      • timeout: number

      Returns BroadcastOperator<DecorateAcknowledgements<EmitEvents>, SocketData>

      const sockets = await io.fetchSockets();

      for (const socket of sockets) {
      if (someCondition) {
      socket.timeout(1000).emit("some-event", (err) => {
      if (err) {
      // the client did not acknowledge the event in the given delay
      }
      });
      }
      }

      // note: if possible, using a room instead of looping over all sockets is preferable
      io.timeout(1000).to(someConditionRoom).emit("some-event", (err, responses) => {
      // ...
      });