@eclipse-ditto/ditto-javascript-client-dom
Version:
DOM implementation of Eclipse Ditto JavaScript API to be used in browsers.
60 lines • 2.76 kB
TypeScript
/*!
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
import { AbstractResilienceHandler, RequestHandler, ResilienceHandler, ResilienceHandlerFactory, ResilienceHandlerFactoryContextStep, WebSocketImplementation, WebSocketImplementationBuilderHandler, WebSocketStateHandler } from './websocket-resilience-interfaces';
import { DittoProtocolEnvelope, DittoProtocolResponse } from '../../../model/ditto-protocol';
/**
* An implementation of ResilienceHandler without buffering.
*/
export declare class BufferlessResilienceHandler extends AbstractResilienceHandler {
private readonly requests;
private webSocket;
constructor(webSocketBuilder: WebSocketImplementationBuilderHandler, stateHandler: WebSocketStateHandler, requestHandler: RequestHandler, reconnect?: boolean);
sendRequest(id: string, request: DittoProtocolEnvelope): void;
send(message: string): Promise<void>;
handleResponse(correlationId: string, response: DittoProtocolResponse): void;
handleFailure(id: string, reason: any): void;
close(code?: number, reason?: string): void;
/**
* Returns the reason to reject a Promise based on the current state of the connection.
*
* @returns The error to reject with
*/
private connectionProblemRejectionReason;
/**
* Handles the promise for a new web socket. Once the Promise is resolved it will be set as the web socket for the resilience handler.
* If the Promise gets rejected the reconnection process will be stopped and all further requests rejected.
*
* @param promise - The promise for the new web socket
*/
protected resolveWebSocket(promise: Promise<WebSocketImplementation>): void;
/**
* Rejects all ongoing requests.
*
* @param reason - The reason to reject the requests with
*/
protected rejectAllOngoing(reason: object): void;
}
/**
* A Factory for a BufferlessResilienceHandler.
*/
export declare class BufferlessResilienceHandlerFactory extends ResilienceHandlerFactory {
private constructor();
/**
* Provides an instance of BufferlessResilienceHandlerFactory.
*
* @returns The instance of BufferlessResilienceHandlerFactory
*/
static getInstance(): ResilienceHandlerFactoryContextStep;
withRequestHandler(requestHandler: RequestHandler): ResilienceHandler;
}
//# sourceMappingURL=websocket-resilience-handler-bufferless.d.ts.map