Something went wrong on our end
Select Git revision
Monster.DOM.html
-
Volker Schukai authoredVolker Schukai authored
websocket.mjs 7.77 KiB
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
* This file is licensed under the AGPLv3 License.
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {internalSymbol, instanceSymbol} from "../../constants.mjs";
import {isString, isObject} from "../../types/is.mjs";
import {WebConnect} from "../../net/webconnect.mjs";
import {Message} from "../../net/webconnect/message.mjs";
import {Datasource} from "../datasource.mjs";
import {Pathfinder} from "../pathfinder.mjs";
import {Pipe} from "../pipe.mjs";
export {WebSocketDatasource}
/**
* @private
* @type {Symbol}
*
* hint: this name is used in the tests. if you want to change it, please change it in the tests as well.
*/
const webConnectSymbol = Symbol("connection");
/**
*
* @param self
* @param obj
* @returns {*}
*/
function doTransform(type, obj) {
const self = this;
let transformation = self.getOption(type + '.mapping.transformer');
if (transformation !== undefined) {
const pipe = new Pipe(transformation);
const callbacks = self.getOption(type + '.mapping.callbacks')
if (isObject(callbacks)) {
for (const key in callbacks) {
if (callbacks.hasOwnProperty(key) && typeof callbacks[key] === 'function') {
pipe.setCallback(key, callbacks[key]);
}
}
}
obj = pipe.run(obj);
}
return obj;
}
/**
* The RestAPI is a class that enables a REST API server.
*
* @externalExample ../../../example/data/storage/restapi.mjs
* @license AGPLv3
* @since 3.1.0
* @copyright schukai GmbH
* @memberOf Monster.Data.Datasource
* @summary The LocalStorage class encapsulates the access to data objects.
*/
class WebSocketDatasource extends Datasource {
/**
*
* @param {Object} [options] options contains definitions for the datasource.
*/
constructor(options) {