Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Context<ListenEvents, EmitEvents>

Type parameters

  • ListenEvents: EventsMap

  • EmitEvents: EventsMap

Hierarchy

Implements

  • TypedEventBroadcaster<EmitEvents>

Indexable

[key: string]: any

Custom properties.

Constructors

constructor

  • new Context(nsp: Namespace<ListenEvents, EmitEvents>, client: Client<ListenEvents, EmitEvents>, auth: object): Context

Properties

app

Readonly client

client: Client<ListenEvents, EmitEvents>

connected

connected: boolean

data

data: any

Additional information that can be attached to the Socket instance and which will be used in the fetchSockets method

disconnected

disconnected: boolean

Readonly handshake

handshake: Handshake

Readonly id

id: SocketId

logger

logger: ILogger

Readonly nsp

nsp: Namespace<ListenEvents, EmitEvents>

requestContext

requestContext: IMidwayContainer

startTime

startTime: number

Accessors

broadcast

  • get broadcast(): BroadcastOperator<EmitEvents>

conn

  • get conn(): any

local

  • get local(): BroadcastOperator<EmitEvents>

request

  • get request(): IncomingMessage

rooms

  • get rooms(): Set<Room>

volatile

  • get volatile(): this
  • Sets a modifier for a subsequent event emission that the event data may be lost if the client is not ready to receive messages (because of network slowness or other issues, or because they’re connected through long polling and is in the middle of a request-response cycle).

    Returns this

    self

Methods

addListener

  • addListener(event: string | symbol, listener: function): this

compress

  • compress(compress: boolean): this

disconnect

  • disconnect(close?: boolean): this

emit

  • emit<Ev>(ev: Ev, ...args: EventParams<EmitEvents, Ev>): boolean
  • Emits to this client.

    Type parameters

    • Ev: EventNames<EmitEvents>

    Parameters

    • ev: Ev
    • Rest ...args: EventParams<EmitEvents, Ev>

    Returns boolean

    Always returns true.

Protected emitReserved

  • emitReserved<Ev>(ev: Ev, ...args: EventParams<SocketReservedEventsMap, Ev>): boolean
  • Emits a reserved event.

    This method is protected, so that only a class extending StrictEventEmitter can emit its own reserved events.

    Type parameters

    • Ev: EventNames<SocketReservedEventsMap>

    Parameters

    • ev: Ev

      Reserved event name

    • Rest ...args: EventParams<SocketReservedEventsMap, Ev>

      Arguments to emit along with the event

    Returns boolean

Protected emitUntyped

  • emitUntyped(ev: string, ...args: any[]): boolean
  • Emits an event.

    This method is protected, so that only a class extending StrictEventEmitter can get around the strict typing. This is useful for calling emit.apply, which can be called as emitUntyped.apply.

    Parameters

    • ev: string

      Event name

    • Rest ...args: any[]

      Arguments to emit along with the event

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>

except

  • except(room: Room | Room[]): BroadcastOperator<EmitEvents>

getLogger

  • getLogger(name?: string): ILogger

getMaxListeners

  • getMaxListeners(): number

in

  • in(room: Room | Room[]): BroadcastOperator<EmitEvents>

join

  • join(rooms: Room | Array<Room>): Promise<void> | void

leave

  • leave(room: string): Promise<void> | void

listenerCount

  • listenerCount(event: string | symbol): number

listeners

  • listeners<Ev>(event: Ev): ReservedOrUserListener<SocketReservedEventsMap, ListenEvents, Ev>[]

listenersAny

  • listenersAny(): function[]

off

  • off(event: string | symbol, listener: function): this

offAny

  • offAny(listener?: function): this

on

  • on<Ev>(ev: Ev, listener: ReservedOrUserListener<SocketReservedEventsMap, ListenEvents, Ev>): this
  • Adds the listener function as an event listener for ev.

    Type parameters

    • Ev: ReservedOrUserEventNames<SocketReservedEventsMap, ListenEvents>

    Parameters

    • ev: Ev

      Name of the event

    • listener: ReservedOrUserListener<SocketReservedEventsMap, ListenEvents, Ev>

      Callback function

    Returns this

onAny

  • onAny(listener: function): this
  • Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the callback.

    Parameters

    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once<Ev>(ev: Ev, listener: ReservedOrUserListener<SocketReservedEventsMap, ListenEvents, Ev>): this
  • Adds a one-time listener function as an event listener for ev.

    Type parameters

    • Ev: ReservedOrUserEventNames<SocketReservedEventsMap, ListenEvents>

    Parameters

    • ev: Ev

      Name of the event

    • listener: ReservedOrUserListener<SocketReservedEventsMap, ListenEvents, Ev>

      Callback function

    Returns this

prependAny

  • prependAny(listener: function): this
  • Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the callback. The listener is added to the beginning of the listeners array.

    Parameters

    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: function): this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: function): this

rawListeners

  • rawListeners(event: string | symbol): Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this

removeListener

  • removeListener(event: string | symbol, listener: function): this

send

  • send(...args: EventParams<EmitEvents, "message">): this

setMaxListeners

  • setMaxListeners(n: number): this

to

  • to(room: Room | Room[]): BroadcastOperator<EmitEvents>

use

  • use(fn: function): this

write

  • write(...args: EventParams<EmitEvents, "message">): this

Generated using TypeDoc