UNPKG

server-state-sync

Version:
27 lines (26 loc) 1.17 kB
/// <reference types="node" /> import * as Http from 'http'; import SocketClient from './SocketClient'; import { StateConfiguration } from './State'; interface StateSyncerConfiguration { cert: Buffer; key: Buffer; } export default class StateSyncer<T, K> { private webSocketServer; private externalServer; private stateManager; constructor(ssl?: StateSyncerConfiguration); private onUpgrade; private onConnection; private _authenticateClient; useAuthorizationMiddleware: (middleWare: (_: Http.IncomingMessage, callback: (clientInformation: K, success: boolean) => void) => void) => void; createState: (config: StateConfiguration<T, K>, identifier?: string | undefined) => string | null; removeState: (stateIdentifier: string) => boolean; removeAllStates: () => void; connectToState: (socketClient: SocketClient<T, K>, stateIdentifier: string) => void; getValueOfState: (stateIdentifier: string) => T | undefined; updateStateValue: (stateIdentifier: string, updates: Partial<T>, clientInformation: K) => Boolean; start: (port: number) => Promise<void | Error>; } export {};