Skip to content
Snippets Groups Projects
Select Git revision
  • ffae3931f245f5d0e248203474cf9a8cb1bc00e3
  • master default protected
  • 1.31
  • 4.27.0
  • 4.26.0
  • 4.25.5
  • 4.25.4
  • 4.25.3
  • 4.25.2
  • 4.25.1
  • 4.25.0
  • 4.24.3
  • 4.24.2
  • 4.24.1
  • 4.24.0
  • 4.23.6
  • 4.23.5
  • 4.23.4
  • 4.23.3
  • 4.23.2
  • 4.23.1
  • 4.23.0
  • 4.22.3
23 results

Monster.DOM.html

  • 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) {