Options
All
  • Public
  • Public/Protected
  • All
Menu

External module server/internal

Index

Type aliases

AckInfo

AckInfo: ["a" | "b" | null, number[]]

Variables

Const FILENAME_BODY

FILENAME_BODY: "wcardinal.in-worker" = "wcardinal.in-worker"

Const JS_EXTENSION

JS_EXTENSION: ".js" = ".js"

Const MIN_JS_EXTENSION

MIN_JS_EXTENSION: ".min.js" = ".min.js"

Const POLLING_PROTOCOL

POLLING_PROTOCOL: "polling" = "polling"

Const SHARED_POLLING_PROTOCOL

SHARED_POLLING_PROTOCOL: string = SHARED_PROTOCOL + POLLING_PROTOCOL

Const SHARED_PROTOCOL

SHARED_PROTOCOL: "shared-" = "shared-"

Const SHARED_WEBSOCKET_PROTOCOL

SHARED_WEBSOCKET_PROTOCOL: string = SHARED_PROTOCOL + WEBSOCKET_PROTOCOL

Const ServerConstructorImpl

ServerConstructorImpl: ServerConstructor = ServerImpl

Const ServerConstructorWorker

ServerConstructorWorker: ServerConstructor = ( typeof Worker !== "undefined" ?class ServerFacade extends MessageEmitter<string[]> implements Server {private static readonly IN_WORKER_URL = getInWorkerUrl();private _protocol: string | null;private _isConnected: boolean;// Do not rename the following variable to `_settings`.// Variables named `_settings` will not be mangled by UglifyJS.private readonly _sttgs: Settings;private readonly _worker: Worker;constructor( settings: Settings ) {super();this._protocol = null;this._isConnected = false;this._sttgs = settings;settings.bfcached = isBFCached( settings );Logger.getInstance().info( `WebWorker: ${ServerFacade.IN_WORKER_URL}` );const worker = this._worker = new Worker( ServerFacade.IN_WORKER_URL );worker.postMessage( [ MessageType.CREATE, settings ] );worker.addEventListener( "message", ( e ) => {const data = e.data;const type = data[ 0 ];switch( type ) {case MessageType.MESSAGE:this.triggerHandlers( data[ 1 ] );break;case MessageType.TRIGGER:switch( data[ 1 ] ) {case IO_EVENT_CONNECTED:this._isConnected = true;break;case IO_EVENT_DISCONNECTED:this._isConnected = false;break;}this.triggerDirect( data[ 1 ], null, null, null );break;case MessageType.TRIGGER_AND_GET:worker.postMessage([MessageType.TRIGGER_AND_GET,data[ 1 ],this.triggerDirect( data[ 1 ], data[ 2 ], data[ 3 ], [] )]);break;case MessageType.SET_PROTOCOL:this._protocol = data[ 1 ];break;}});}connect(): this {this._worker.postMessage( [ MessageType.CONNECT ] );return this;}disconnect(): this {this._worker.postMessage( [ MessageType.DISCONNECT ] );return this;}isConnected(): boolean {return this._isConnected;}setProtocol( protocol: string ): this {this._worker.postMessage( [ MessageType.SET_PROTOCOL, protocol ] );return this;}getProtocol( allowedProtocols?: PlainObject<IoSettings> ): string | null {return ServerBase.findProtocol_( this._protocol, allowedProtocols );}getSettings(): Settings {return this._sttgs;}send( type: string, content: unknown ) {const messageString = ServerBase.toMessageString_( type, content );if( messageString != null ) {this._worker.postMessage( [ MessageType.SEND, messageString ] );}return this;}ajax(mode: string, data: BodyInit | null, timeout: number, onSuccess: AjaxSuccessHandler,onError: AjaxErrorHandler, context?: unknown): void {sendAjaxRequest( this._sttgs, mode, data, timeout, onSuccess, onError, context );}} :ServerImpl)

Const WEBSOCKET_PROTOCOL

WEBSOCKET_PROTOCOL: "websocket" = "websocket"

Functions

Const checkConnectingResults

  • checkConnectingResults(results: unknown[] | null | undefined): boolean

Const getInWorkerUrl

  • getInWorkerUrl(): string

Const isBFCached

  • isBFCached(settings: Settings): boolean

Const makeServerUrl

  • makeServerUrl(settings: Settings): string

Const sendAjaxRequest

Const toServerHeaders

  • toServerHeaders(mode: string, ssid: string): PlainObject<string>

Object literals

Const serverTriggers

serverTriggers: object

_trigger

  • _trigger(name: string): void

_triggerAndGet

  • _triggerAndGet(name: string, type: string[] | null, data: unknown[] | null): unknown[]

_triggerHandlers

  • _triggerHandlers(messages: string[]): void

Generated using TypeDoc