Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MailStation

Mail station constructor.

param

construct parameters

Hierarchy

  • EventEmitter
    • MailStation

Index

Constructors

constructor

Properties

afters

afters: Array<RpcFilter> = []

befores

befores: Array<RpcFilter> = []

connecting

connecting: object

Type declaration

  • [serverId: string]: boolean

Optional handleError

mailboxFactory

mailboxFactory: MailBoxFactory

mailboxes

mailboxes: object

Type declaration

onlines

onlines: object

Type declaration

  • [serverId: string]: number

opts

pendingSize

pendingSize: number

pendings

pendings: object

Type declaration

  • [serverId: string]: IArguments[]

servers

servers: object

Type declaration

serversMap

serversMap: object

Type declaration

  • [serverType: string]: string[]

state

state: number = STATE_INITED

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

addServer

  • Add a new server info into the mail station and clear the blackhole associated with the server id if any before.

    Parameters

    Returns void

addServers

after

before

clearStation

  • clearStation(): void

connect

  • connect(this: any, tracer: Tracer, serverId: string, cb: Function): void
  • Try to connect to remote server

    Parameters

    • this: any
    • tracer: Tracer

      rpc debug tracer

    • serverId: string
    • cb: Function

      callback function

    Returns void

    serverId remote server id

dispatch

  • Dispatch rpc message to the mailbox

    Parameters

    • tracer: Tracer

      rpc debug tracer

    • serverId: string

      remote server id

    • msg: MailBoxMessage

      rpc invoke message

    • opts: object

      rpc invoke option args

    • cb: function

      callback function

        • (err: Error, ...args: any[]): void
        • Parameters

          • err: Error
          • Rest ...args: any[]

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

filter

getMaxListeners

  • getMaxListeners(): number
  • Returns 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[]

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

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

removeServer

  • removeServer(this: any, id: string | number): void
  • Remove a server info from the mail station and remove the mailbox instance associated with the server id.

    Parameters

    • this: any
    • id: string | number

      server id

    Returns void

removeServers

  • removeServers(ids: Array<string | number>): void
  • Batch version for remove remote servers.

    Parameters

    • ids: Array<string | number>

      server id list

    Returns void

replaceServers

  • replaceServers(this: any, serverInfos: Array<RpcServerInfo>): void

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

start

  • start(cb: function): void
  • Init and start station. Connect all mailbox to remote servers.

    Parameters

    • cb: function
        • (err?: Error): void
        • Parameters

          • Optional err: Error

          Returns void

    Returns void

stop

  • stop(force: boolean): void
  • Stop station and all its mailboxes

    Parameters

    • force: boolean

      whether stop station forcely

    Returns void

Static listenerCount

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

    • emitter: EventEmitter
    • event: string | symbol

    Returns number