Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WebSocketServer

Hierarchy

Index

Constructors

constructor

Properties

attributes

attributes: object

attributes of the server

Type declaration

  • [key: string]: any

canChat

canChat: boolean

Can connections of this server use the chat system?

Optional config

config: ServerConfig

Shorthand for api.config.servers[this.type]

connectionCustomMethods

connectionCustomMethods: object

Methods described by the server to apply to each connection (like connection.setHeader for web connections)

Type declaration

  • [key: string]: Function

logConnections

logConnections: boolean

Should we log every new connection?

logExits

logExits: boolean

Should we log when a connection disconnects/exits?

Optional options

options: object

Type declaration

  • [key: string]: any

sendWelcomeMessage

sendWelcomeMessage: boolean

Should every new connection of this server type receive the welcome message (defined in locales, actionhero.welcomeMessage)

server

server: any

type

type: string

The name & type of the server.

Optional verbs

verbs: Array<string>

What connection verbs can connections of this type use?

Static defaultMaxListeners

defaultMaxListeners: number

Methods

addListener

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

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

          • Rest ...args: any[]

          Returns void

    Returns this

buildConnection

  • buildConnection(data: any): Promise<void>
    • Build a the ActionHero.Connection from the raw parts provided by the server.
      this.buildConnection({
      rawConnection: {
      req: req,
      res: res,
      params: {},
      method: method,
      cookies: cookies,
      responseHeaders: responseHeaders,
      responseHttpCode: responseHttpCode,
      parsedURL: parsedURL
      },
      id: fingerprint + '-' + uuid.v4(),
      fingerprint: fingerprint,
      remoteAddress: remoteIP,
      remotePort: remotePort
      })

    Parameters

    • data: any

    Returns Promise<void>

compileActionheroWebsocketClientJS

  • compileActionheroWebsocketClientJS(): string

connections

defaultAttributes

  • defaultAttributes(): object

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
  • Returns number

goodbye

handleConnection

  • handleConnection(rawConnection: any): void

handleData

  • handleData(connection: any, data: any): Promise<void>

handleDisconnection

  • handleDisconnection(rawConnection: any): void

initialize

  • initialize(): Promise<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[]

log

  • log(message: string, severity?: string, data?: any): void
  • Log a message from this server type. A wrapper around log() with a server prefix.

    Parameters

    • message: string
    • Optional severity: string
    • Optional data: any

    Returns void

off

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

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

          • Rest ...args: any[]

          Returns void

    Returns this

on

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

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

          • Rest ...args: any[]

          Returns void

    Returns this

once

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

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

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

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

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

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

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

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

          • Rest ...args: any[]

          Returns void

    Returns this

processAction

  • processAction(connection: Connection): Promise<void>
  • When a connection has called an Action command, and all properties are set. Connection should have params.action set at least. on(event: 'actionComplete', cb: (data: object) => void): this;

    Parameters

    Returns Promise<void>

processFile

  • processFile(connection: Connection): Promise<void>
  • When a connection has called an File command, and all properties are set. Connection should have params.file set at least. Will eventually call ActionHero.Server#sendFile.

    Parameters

    Returns Promise<void>

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: function): this
  • Parameters

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

          • Rest ...args: any[]

          Returns void

    Returns this

renderClientJS

  • renderClientJS(minimize: any): any

sendFile

  • sendFile(connection: Connection, error: Error, fileStream: any, mime: string, length: number, lastModified: Date): Promise<void>

sendMessage

  • sendMessage(connection: Connection, message: any, messageId: string): Promise<void>

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

start

  • start(): Promise<void>

stop

  • stop(): Promise<void>

validate

  • validate(): void

writeClientJS

  • writeClientJS(): void

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc