tgrid
Version:
Grid Computing Framework for TypeScript
92 lines (91 loc) • 3.28 kB
TypeScript
import { Invoke } from "../../components/Invoke";
import { AcceptorBase } from "../internal/AcceptorBase";
import { IWorkerSystem } from "./internal/IWorkerSystem";
/**
* SharedWorker acceptor for client.
*
* - available only in the Web Browser.
*
* The `SharedWorkerAcceptor` is a communicator class interacting with the
* {@link SharedWorkerConnector} through RFC (Remote Function Call), created by
* the {@link SharedWorkerServer} class whenever a client connects to the
* `SharedWorker` instance.
*
* When a remote client connects to the {@link SharedWorkerServer},
* so that a new `SharedworkerAcceptor` instance being created, you can determine
* whether to {@link accept} the client's connection or {@link reject not},
* reading the {@link header} property. If you've decided to accept the connection,
* call the {@link accept} method with `Provider` instance. Otherwise, reject it
* thorugh the {@link reject} method.
*
* After {@link accept accepting} the connection, don't forget to
* {@link close closing} the connection after your business has been completed
* to clean up the resources. Otherwise the closing must be performed by the remote
* client, you can wait the remote client's closing signal by the {@link join} method.
*
* Also, when declaring this {@link SharedworkerAcceptor} type, you have to define three
* generic arguments; `Header`, `Provider` and `Remote`. Those generic arguments must
* be same with the ones defined in the {@link SharedWorkerServer} class.
*
* For reference, the first `Header` type represents an initial data from the
* remote client after the connection. I recommend utilize it as an activation tool
* for security enhancement. The second generic argument `Provider` represents a
* provider from server to client, and the other `Remote` means a provider from the
* remote client to server.
*
* @template Header Type of the header containing initial data.
* @template Provider Type of features provided for the remote client.
* @template Remote Type of features provided by remote client.
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class SharedWorkerAcceptor<Header, Provider extends object | null, Remote extends object | null> extends AcceptorBase<Header, Provider, Remote> implements IWorkerSystem {
/**
* @hidden
*/
private port_;
/**
* @hidden
*/
private eraser_;
/**
* @hidden
*/
private constructor();
/**
* @inheritDoc
*/
close(): Promise<void>;
/**
* @hidden
*/
private _Close;
/**
* @inheritDoc
*/
accept(provider: Provider): Promise<void>;
/**
* Reject connection.
*
* Reject without acceptance, any interaction. The connection would be closed immediately.
*
* @param reason Detailed reason of the rejection. Default is "Rejected by server".
*/
reject(reason?: string): Promise<void>;
/**
* @hidden
*/
protected sendData(invoke: Invoke): Promise<void>;
/**
* @hidden
*/
private _Handle_message;
}
/**
*
*/
export declare namespace SharedWorkerAcceptor {
/**
* Current state of the {@link SharedWorkerAcceptor}.
*/
export import State = AcceptorBase.State;
}