"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const socket_wrapper_1 = require("../../base/socket-wrapper");
class JSONSocketWrapper extends socket_wrapper_1.WSSocketWrapper {
    constructor() {
        super(...arguments);
        this.socketType = 'wsJSON';
    }
    getMessage(message) {
        return JSON.stringify(message);
    }
    getAckMessage(message) {
        return this.getMessage(message);
    }
    parseMessage(message) {
        if (typeof message !== 'string') {
            this.invalidTypeReceived();
            return [];
        }
        try {
            return [JSON.parse(message)];
        }
        catch (e) {
            this.invalidTypeReceived();
            return [];
        }
    }
    parseData(message) {
        try {
            if (message.data) {
                message.parsedData = JSON.parse(message.data);
            }
            return true;
        }
        catch (e) {
            return e;
        }
    }
}
exports.JSONSocketWrapper = JSONSocketWrapper;
exports.createWSSocketWrapper = function (socket, handshakeData, services, config, connectionEndpoint) { return new JSONSocketWrapper(socket, handshakeData, services, config, connectionEndpoint, false); };
//# sourceMappingURL=socket-wrapper-factory.js.map