Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Server

Hierarchy

Index

Constructors

constructor

  • Parameters

    • Optional options: ServerOptions
    • Optional callback: undefined | (() => void)

    Returns Server

Properties

clients

clients: Set<WebSocket>

options

options: ServerOptions

path

path: string

Methods

addListener

  • addListener(event: "connection", cb: (client: WebSocket) => void): this
  • addListener(event: "error", cb: (err: Error) => void): this
  • addListener(event: "headers", cb: (headers: string[], request: IncomingMessage) => void): this
  • addListener(event: "close" | "listening", cb: () => void): this
  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    Returns this

  • Parameters

    • event: "error"
    • cb: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns this

  • Parameters

    • event: "headers"
    • cb: (headers: string[], request: IncomingMessage) => void
        • (headers: string[], request: IncomingMessage): void
        • Parameters

          • headers: string[]
          • request: IncomingMessage

          Returns void

    Returns this

  • Parameters

    • event: "close" | "listening"
    • cb: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

address

  • Returns AddressInfo | string

close

  • close(cb?: undefined | ((err?: Error) => void)): void
  • Parameters

    • Optional cb: undefined | ((err?: Error) => void)

    Returns void

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

getMaxListeners

  • getMaxListeners(): number

handleUpgrade

  • handleUpgrade(request: IncomingMessage, socket: Socket, upgradeHead: Buffer, callback: (client: WebSocket) => void): void
  • Parameters

    • request: IncomingMessage
    • socket: Socket
    • upgradeHead: Buffer
    • callback: (client: WebSocket) => void

    Returns void

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: "connection", cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void): this
  • on(event: "error", cb: (this: Server, error: Error) => void): this
  • on(event: "headers", cb: (this: Server, headers: string[], request: IncomingMessage) => void): this
  • on(event: "close" | "listening", cb: (this: Server) => void): this
  • on(event: string | symbol, listener: (this: Server, ...args: any[]) => void): this
  • Parameters

    • event: "connection"
    • cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void

    Returns this

  • Parameters

    • event: "error"
    • cb: (this: Server, error: Error) => void
        • (this: Server, error: Error): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "headers"
    • cb: (this: Server, headers: string[], request: IncomingMessage) => void
        • (this: Server, headers: string[], request: IncomingMessage): void
        • Parameters

          • this: Server
          • headers: string[]
          • request: IncomingMessage

          Returns void

    Returns this

  • Parameters

    • event: "close" | "listening"
    • cb: (this: Server) => void

    Returns this

  • Parameters

    • event: string | symbol
    • listener: (this: Server, ...args: any[]) => void
        • (this: Server, ...args: any[]): void
        • Parameters

          • this: Server
          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

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

    • event: string | symbol

    Returns Function[]

removeAllListeners

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

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

setMaxListeners

  • setMaxListeners(n: number): this

shouldHandle

  • shouldHandle(request: IncomingMessage): boolean
  • Parameters

    • request: IncomingMessage

    Returns boolean

Generated using TypeDoc