Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MutexAcceptor<Header, Provider>

Acceptor of the mutex-server.

The MutexAcceptor is a communicator class interacting with the remote client, through websocket and RFC protocol, in the mutex-server. The MutexAcceptor objects are always created by the MutexServer class, whenever a remote client connects to the mutex-server.

You can accept or reject the client's connection by calling accept or reject method. If you accept the connection, the interaction would be started and the client can access to critical component sections of this mutex-server.

Also, when declaring this MutexAcceptor type, you've to define two template arguments, Header and Provider*. The *Header type repersents an initial data gotten from the remote client after the connection. I hope you and client not to omit it and utilize it as an activation tool to enhance security.

The second template argument Provider represents the additional features provided for the remote client. If you don't have any plan to provide additional feature to the remote client, just declare it as null

author

Jeongho Nam - https://github.com/samchon

Type parameters

  • Header

    Type of the header containing initial data.

  • Provider: object | null

    Type of additional features provided for the remote client.

Hierarchy

  • MutexAcceptor

Index

Properties

Accessors

Methods

Properties

Static State

State: State

Current state of the MutexAcceptor

Accessors

header

  • get header(): Header
  • Header containing initialization data like activation.

    Returns Header

ip

  • get ip(): string
  • IP Address of client.

    Returns string

path

  • get path(): string
  • Path of client has connected.

    Returns string

state

  • Get state.

    Get current state of connection state with the remote client. List of values are such like below:

    • REJECTING: The {@link MutexConnector.reject} method is on running.
    • NONE: The MutexAcceptor instance is newly created, but did nothing yet.
    • ACCEPTING: The MutexConnector.connect method is on running.
    • OPEN: The connection is online.
    • CLOSING: The MutexConnector.close method is on running.
    • CLOSED: The connection is offline.

    Returns State

Methods

accept

  • accept(provider: Provider): Promise<void>
  • Accept connection.

    Accepts, permits the client's connection to this mutex-server and starts interaction.

    Parameters

    • provider: Provider

      An object providing additional features for the remote client. If you don't have plan to proivde any additional feature, assign null.

    Returns Promise<void>

close

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

    Close connection with the remote client.

    When connection with the remote client has been closed, all of the locks the client had acquired and tried would be automatically unlocked and cancelled by this mutex-server. Also, remote critical section components had assigned to the client would be returned, too.

    In addition, the disconnection destories all RFCs between the remote client. Therefore, if the remote client is providing custom features to your mutex-server and there're uncompleted method calls to the Provider through Driver<Controller>, RuntimeError exceptions would be thrown.

    throw

    DomainError when the connection is not online.

    Parameters

    • Optional code: undefined | number

      Closing code.

    • Optional reason: undefined | string

      Reason why.

    Returns Promise<void>

getDriver

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

    If remote client provides custom features for this mutex-server, you can utilize those features thorugh returned Driver object by this method. To use this method, you should define the Controller template argument, a type of interface who is defining additionla features provided from the remote client.

    The returned object Driver makes to call remote functions, defined in the Controller and provided by Provider in the remote client, possible. In other words, callling a function in the Driver<Controller>, it means to call a matched function in the remote client's Provider object.

    Type parameters

    • Controller: object

      An interface for provided features (functions & objects) from the remote client (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.

join

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

    Wait until connection with the server to be closed.

    Returns Promise<void>

  • Join connection until timeout.

    Wait until connection with the server to be clsoed until timeout.

    Parameters

    • ms: number

      The maximum miliseconds for waiting.

    Returns Promise<boolean>

    Whether succeeded to waiting in the given time.

  • Join connection until time expiration.

    Wait until connection with the server to be closed until time expiration.

    Parameters

    • at: Date

      The maximum time point to wait.

    Returns Promise<boolean>

    Whether succeeded to waiting in the given time.

reject

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

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

    Parameters

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

      Reason why.

    Returns Promise<void>

Generated using TypeDoc