Echo default plugin

All received messages will be sent back on the same connection.

Client A connects to instance K and sends message M then K sends M to A.

Code

'use strict';

/**
 * @constructor
 * @struct
 * @see {!PluginWorker}
 */
function EchoPlugin() {
    /**
     * @param {WebSocketMessage} message
     * @param {WebSocketConnection} connection
     */
    this.onMessage = (message, connection) => {
        connection.send(message.data);
    }
}

/**
 * @type {!Plugin}
 */
module.exports = {
    name: 'echo',
    description: 'Every received message will be send back',
    createWorker: () => new EchoPlugin()
};