Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ClientSocket

Hierarchy

Index

Type aliases

CertMeta

CertMeta: string | string[] | Buffer | Buffer[]

CertMeta represents the accepted types for certificate & key data.

Data

Data: string | Buffer | ArrayBuffer | Buffer[]

Data represents the message payload received over the WebSocket.

VerifyClientCallbackAsync

VerifyClientCallbackAsync: (info: { origin: string; req: IncomingMessage; secure: boolean }, callback: (res: boolean, code?: undefined | number, message?: undefined | string, headers?: http.OutgoingHttpHeaders) => void) => void

VerifyClientCallbackAsync is an asynchronous callback used to inspect the incoming message. The return value (boolean) of the function determines whether or not to accept the handshake.

Type declaration

    • (info: { origin: string; req: IncomingMessage; secure: boolean }, callback: (res: boolean, code?: undefined | number, message?: undefined | string, headers?: http.OutgoingHttpHeaders) => void): void
    • Parameters

      • info: { origin: string; req: IncomingMessage; secure: boolean }
        • origin: string
        • req: IncomingMessage
        • secure: boolean
      • callback: (res: boolean, code?: undefined | number, message?: undefined | string, headers?: http.OutgoingHttpHeaders) => void
          • (res: boolean, code?: undefined | number, message?: undefined | string, headers?: http.OutgoingHttpHeaders): void
          • Parameters

            • res: boolean
            • Optional code: undefined | number
            • Optional message: undefined | string
            • Optional headers: http.OutgoingHttpHeaders

            Returns void

      Returns void

VerifyClientCallbackSync

VerifyClientCallbackSync: (info: { origin: string; req: IncomingMessage; secure: boolean }) => boolean

VerifyClientCallbackSync is a synchronous callback used to inspect the incoming message. The return value (boolean) of the function determines whether or not to accept the handshake.

Type declaration

    • (info: { origin: string; req: IncomingMessage; secure: boolean }): boolean
    • Parameters

      • info: { origin: string; req: IncomingMessage; secure: boolean }
        • origin: string
        • req: IncomingMessage
        • secure: boolean

      Returns boolean

Constructors

constructor

Properties

CLOSED

CLOSED: number

CLOSING

CLOSING: number

CONNECTING

CONNECTING: number

OPEN

OPEN: number

binaryType

binaryType: string

bufferedAmount

bufferedAmount: number

extensions

extensions: string

onclose

onclose: (event: CloseEvent) => void

Type declaration

onerror

onerror: (event: ErrorEvent) => void

Type declaration

onmessage

onmessage: (event: MessageEvent) => void

Type declaration

onopen

onopen: (event: OpenEvent) => void

Type declaration

protocol

protocol: string

readyState

readyState: number

token

token: Id

Unique token id of the client

url

url: string

Static CLOSED

CLOSED: number

Static CLOSING

CLOSING: number

Static CONNECTING

CONNECTING: number

Static OPEN

OPEN: number

Methods

addEventListener

  • addEventListener(method: "message", cb?: undefined | ((event: { data: any; target: WebSocket; type: string }) => void)): void
  • addEventListener(method: "close", cb?: undefined | ((event: { code: number; reason: string; target: WebSocket; wasClean: boolean }) => void)): void
  • addEventListener(method: "error", cb?: undefined | ((event: { error: any; message: any; target: WebSocket; type: string }) => void)): void
  • addEventListener(method: "open", cb?: undefined | ((event: { target: WebSocket }) => void)): void
  • addEventListener(method: string, listener?: undefined | (() => void)): void
  • Parameters

    • method: "message"
    • Optional cb: undefined | ((event: { data: any; target: WebSocket; type: string }) => void)

    Returns void

  • Parameters

    • method: "close"
    • Optional cb: undefined | ((event: { code: number; reason: string; target: WebSocket; wasClean: boolean }) => void)

    Returns void

  • Parameters

    • method: "error"
    • Optional cb: undefined | ((event: { error: any; message: any; target: WebSocket; type: string }) => void)

    Returns void

  • Parameters

    • method: "open"
    • Optional cb: undefined | ((event: { target: WebSocket }) => void)

    Returns void

  • Parameters

    • method: string
    • Optional listener: undefined | (() => void)

    Returns void

addListener

  • addListener(event: "close", listener: (code: number, message: string) => void): this
  • addListener(event: "error", listener: (err: Error) => void): this
  • addListener(event: "upgrade", listener: (request: IncomingMessage) => void): this
  • addListener(event: "message", listener: (data: WebSocket.Data) => void): this
  • addListener(event: "open", listener: () => void): this
  • addListener(event: "ping" | "pong", listener: (data: Buffer) => void): this
  • addListener(event: "unexpected-response", listener: (request: ClientRequest, response: IncomingMessage) => void): this
  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: "close"
    • listener: (code: number, message: string) => void
        • (code: number, message: string): void
        • Parameters

          • code: number
          • message: string

          Returns void

    Returns this

  • Parameters

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

          • err: Error

          Returns void

    Returns this

  • Parameters

    • event: "upgrade"
    • listener: (request: IncomingMessage) => void
        • (request: IncomingMessage): void
        • Parameters

          • request: IncomingMessage

          Returns void

    Returns this

  • Parameters

    • event: "message"
    • listener: (data: WebSocket.Data) => void
        • (data: WebSocket.Data): void
        • Parameters

          • data: WebSocket.Data

          Returns void

    Returns this

  • Parameters

    • event: "open"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "ping" | "pong"
    • listener: (data: Buffer) => void
        • (data: Buffer): void
        • Parameters

          • data: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "unexpected-response"
    • listener: (request: ClientRequest, response: IncomingMessage) => void
        • (request: ClientRequest, response: IncomingMessage): void
        • Parameters

          • request: ClientRequest
          • response: IncomingMessage

          Returns void

    Returns this

  • Parameters

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

          • Rest ...args: any[]

          Returns void

    Returns this

close

  • close(code?: undefined | number, data?: undefined | string): void
  • Parameters

    • Optional code: undefined | number
    • Optional data: undefined | string

    Returns void

createWebSocketStream

  • createWebSocketStream(websocket: WebSocket, options: stream.DuplexOptions): stream.Duplex
  • Parameters

    • websocket: WebSocket
    • options: stream.DuplexOptions

    Returns stream.Duplex

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

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: "close", listener: (this: WebSocket, code: number, reason: string) => void): this
  • on(event: "error", listener: (this: WebSocket, err: Error) => void): this
  • on(event: "upgrade", listener: (this: WebSocket, request: IncomingMessage) => void): this
  • on(event: "message", listener: (this: WebSocket, data: WebSocket.Data) => void): this
  • on(event: "open", listener: (this: WebSocket) => void): this
  • on(event: "ping" | "pong", listener: (this: WebSocket, data: Buffer) => void): this
  • on(event: "unexpected-response", listener: (this: WebSocket, request: ClientRequest, response: IncomingMessage) => void): this
  • on(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this
  • Parameters

    • event: "close"
    • listener: (this: WebSocket, code: number, reason: string) => void
        • (this: WebSocket, code: number, reason: string): void
        • Parameters

          • this: WebSocket
          • code: number
          • reason: string

          Returns void

    Returns this

  • Parameters

    • event: "error"
    • listener: (this: WebSocket, err: Error) => void

    Returns this

  • Parameters

    • event: "upgrade"
    • listener: (this: WebSocket, request: IncomingMessage) => void
        • (this: WebSocket, request: IncomingMessage): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "message"
    • listener: (this: WebSocket, data: WebSocket.Data) => void
        • (this: WebSocket, data: WebSocket.Data): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    Returns this

  • Parameters

    • event: "ping" | "pong"
    • listener: (this: WebSocket, data: Buffer) => void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "unexpected-response"
    • listener: (this: WebSocket, request: ClientRequest, response: IncomingMessage) => void
        • (this: WebSocket, request: ClientRequest, response: IncomingMessage): void
        • Parameters

          • this: WebSocket
          • request: ClientRequest
          • response: IncomingMessage

          Returns void

    Returns this

  • Parameters

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

          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

ping

  • ping(data?: any, mask?: undefined | false | true, cb?: undefined | ((err: Error) => void)): void
  • Parameters

    • Optional data: any
    • Optional mask: undefined | false | true
    • Optional cb: undefined | ((err: Error) => void)

    Returns void

pong

  • pong(data?: any, mask?: undefined | false | true, cb?: undefined | ((err: Error) => void)): void
  • Parameters

    • Optional data: any
    • Optional mask: undefined | false | true
    • Optional cb: undefined | ((err: Error) => void)

    Returns void

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

removeEventListener

  • removeEventListener(method: "message", cb?: undefined | ((event: { data: any; target: WebSocket; type: string }) => void)): void
  • removeEventListener(method: "close", cb?: undefined | ((event: { code: number; reason: string; target: WebSocket; wasClean: boolean }) => void)): void
  • removeEventListener(method: "error", cb?: undefined | ((event: { error: any; message: any; target: WebSocket; type: string }) => void)): void
  • removeEventListener(method: "open", cb?: undefined | ((event: { target: WebSocket }) => void)): void
  • removeEventListener(method: string, listener?: undefined | (() => void)): void
  • Parameters

    • method: "message"
    • Optional cb: undefined | ((event: { data: any; target: WebSocket; type: string }) => void)

    Returns void

  • Parameters

    • method: "close"
    • Optional cb: undefined | ((event: { code: number; reason: string; target: WebSocket; wasClean: boolean }) => void)

    Returns void

  • Parameters

    • method: "error"
    • Optional cb: undefined | ((event: { error: any; message: any; target: WebSocket; type: string }) => void)

    Returns void

  • Parameters

    • method: "open"
    • Optional cb: undefined | ((event: { target: WebSocket }) => void)

    Returns void

  • Parameters

    • method: string
    • Optional listener: undefined | (() => void)

    Returns void

removeListener

  • removeListener(event: "close", listener: (code: number, message: string) => void): this
  • removeListener(event: "error", listener: (err: Error) => void): this
  • removeListener(event: "upgrade", listener: (request: IncomingMessage) => void): this
  • removeListener(event: "message", listener: (data: WebSocket.Data) => void): this
  • removeListener(event: "open", listener: () => void): this
  • removeListener(event: "ping" | "pong", listener: (data: Buffer) => void): this
  • removeListener(event: "unexpected-response", listener: (request: ClientRequest, response: IncomingMessage) => void): this
  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: "close"
    • listener: (code: number, message: string) => void
        • (code: number, message: string): void
        • Parameters

          • code: number
          • message: string

          Returns void

    Returns this

  • Parameters

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

          • err: Error

          Returns void

    Returns this

  • Parameters

    • event: "upgrade"
    • listener: (request: IncomingMessage) => void
        • (request: IncomingMessage): void
        • Parameters

          • request: IncomingMessage

          Returns void

    Returns this

  • Parameters

    • event: "message"
    • listener: (data: WebSocket.Data) => void
        • (data: WebSocket.Data): void
        • Parameters

          • data: WebSocket.Data

          Returns void

    Returns this

  • Parameters

    • event: "open"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "ping" | "pong"
    • listener: (data: Buffer) => void
        • (data: Buffer): void
        • Parameters

          • data: Buffer

          Returns void

    Returns this

  • Parameters

    • event: "unexpected-response"
    • listener: (request: ClientRequest, response: IncomingMessage) => void
        • (request: ClientRequest, response: IncomingMessage): void
        • Parameters

          • request: ClientRequest
          • response: IncomingMessage

          Returns void

    Returns this

  • Parameters

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

          • Rest ...args: any[]

          Returns void

    Returns this

send

  • send(data: any, cb?: undefined | ((err?: Error) => void)): void
  • send(data: any, options: { binary?: undefined | false | true; compress?: undefined | false | true; fin?: undefined | false | true; mask?: undefined | false | true }, cb?: undefined | ((err?: Error) => void)): void
  • Parameters

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

    Returns void

  • Parameters

    • data: any
    • options: { binary?: undefined | false | true; compress?: undefined | false | true; fin?: undefined | false | true; mask?: undefined | false | true }
      • Optional binary?: undefined | false | true
      • Optional compress?: undefined | false | true
      • Optional fin?: undefined | false | true
      • Optional mask?: undefined | false | true
    • Optional cb: undefined | ((err?: Error) => void)

    Returns void

setMaxListeners

  • setMaxListeners(n: number): this

terminate

  • terminate(): void

Generated using TypeDoc