• Public
  • Public/Protected
  • All

Class WebAcceptor<Provider>

Web Socket Acceptor.

  • available only in NodeJS.

The WebAcceptor is a communicator class interacting with the remote (web socket) client using RFC (Remote Function Call). The WebAcceptor objects are always created by the WebServer class whenever a remote client connects to its server.

To accept connection and start interaction with the remote client, call the accept() method with special Provider. Also, don't forget to closing the connection after your busines has been completed.


Jeongho Nam http://samchon.org

Type parameters

  • Provider: object

    Type of features provided for remote system.






  • get path(): string


  • get state(): WebAcceptor.State



  • accept(provider?: Provider | null): Promise<void>


  • close(code?: undefined | number, reason?: undefined | string): Promise<void>
  • Close connection.

    Close connection with the remote websocket system.

    It destories all RFCs (remote function calls) between this and remote websocket system (through Driver<Controller>) that are not returned (completed) yet. The destruction causes all incompleted RFCs to throw exceptions.

    If parametric code and reason are specified, it means the disconnection is abnormal and it would throw special exceptions (WebError) to the incompleted RFCs.


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

    Returns Promise<void>


  • getDriver<Controller, UseParametric>(): Driver<Controller, UseParametric>
  • Get Driver for RFC (Remote Function Call).

    The Controller is an interface who defines provided functions from the remote system. The Driver is an object who makes to call remote functions, defined in the Controller and provided by Provider in the remote system, possible.

    In other words, calling a functions in the Driver<Controller>, it means to call a matched function in the remote system's Provider object.

    • Controller: Definition only
    • Driver: Remote Function Call

    Type parameters

    • Controller: object

      An interface for provided features (functions & objects) from the remote system (Provider).

    • UseParametric: boolean

      Whether to convert type of function parameters to be compatible with their pritimive.

    Returns Driver<Controller, UseParametric>

    A Driver for the RFC.


  • getProvider(): Provider | null | undefined
  • Get current Provider.

    Get an object providing features (functions & objects) for remote system. The remote system would call the features (Provider) by using its Driver<Controller>.

    Returns Provider | null | undefined

    Current Provider object


  • join(): Promise<void>
  • join(ms: number): Promise<boolean>
  • join(at: Date): Promise<boolean>


  • reject(status?: undefined | number, reason?: undefined | string, extraHeaders?: undefined | object): Promise<void>
  • Reject connection.

    Reject without acceptance, any interaction. The connection would be closed immediately.


    • Optional status: undefined | number

      Status code.

    • Optional reason: undefined | string

      Detailed reason to reject.

    • Optional extraHeaders: undefined | object

      Extra headers if required.

    Returns Promise<void>

Protected replyData

  • replyData(invoke: Invoke): void
  • Data Reply Function.

    A function should be called when data has come from the remote system.

    When you receive a message from the remote system, then parse the message with your special protocol and covert it to be an Invoke object. After the conversion, call this method.


    • invoke: Invoke

      Structured data converted by your special protocol.

    Returns void


  • setProvider(obj: Provider | null | undefined): void

Static create

  • create<Provider>(request: request): WebAcceptor<Provider>

Generated using TypeDoc