@eclipse-ditto/ditto-javascript-client-node
Version:
Node.js(r) implementation of Eclipse Ditto JavaScript API.
62 lines • 2.79 kB
JavaScript
;
/*!
* 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
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultDittoWebSocketClient = void 0;
const messages_websocket_1 = require("./handles/messages-websocket");
const commands_1 = require("./handles/commands");
const ditto_client_1 = require("./ditto-client");
const things_1 = require("./handles/things");
const features_1 = require("./handles/features");
const events_websocket_1 = require("./handles/events-websocket");
class DefaultHandles {
constructor() {
this.thingsHandle = things_1.DefaultThingsHandle.getInstance;
this.featuresHandle = features_1.DefaultFeaturesHandle.getInstance;
this.eventsHandle = events_websocket_1.WebSocketEventsHandle.getInstance;
this.messagesHandle = messages_websocket_1.DefaultWebSocketMessagesHandle.getInstance;
this.commandsHandle = commands_1.DefaultCommandsHandle.getInstance;
}
}
class DefaultDittoWebSocketClient extends ditto_client_1.AbstractDittoClient {
constructor(builder, responseHandler, handles) {
super(builder, handles);
this.responseHandler = responseHandler;
}
/**
* Returns an instance of DittoClient based on the context provided.
*
* @param requestSenderFactory - The request sender factory to use.
* @param requester - The requester to use.
* @param customHandles - custom handles to use with the client.
* @return the DittoClient instance.
*/
static getInstance(requestSenderFactory, requester, customHandles) {
const handles = Object.assign(new DefaultHandles(), customHandles);
return new DefaultDittoWebSocketClient(requestSenderFactory, requester, handles);
}
getThingsHandle(customBuildContext) {
return this.handles.thingsHandle(this.builder, customBuildContext);
}
getEventsHandle(customBuildContext) {
return this.handles.eventsHandle(this.builder, this.responseHandler, customBuildContext);
}
getMessagesHandle(customBuildContext) {
return this.handles.messagesHandle(this.builder, this.responseHandler, customBuildContext);
}
getCommandsHandle(customBuildContext) {
return this.handles.commandsHandle(this.builder, this.responseHandler, customBuildContext);
}
}
exports.DefaultDittoWebSocketClient = DefaultDittoWebSocketClient;
//# sourceMappingURL=ditto-client-websocket.js.map