Sha256: 631e1b34c7fa99ab6232c96c01dd993b5c459ac81edfa9d302b33e1768ac8603

Contents?: true

Size: 1.52 KB

Versions: 8

Compression:

Stored size: 1.52 KB

Contents

const { Handler } = require('../handler/Handler')
const CommandSerializer = require('../protocol/CommandSerializer')
const CommandDeserializer = require('../protocol/CommandDeserializer')
const Runtime = require("../../utils/RuntimeName");

let Transmitter
let Receiver

class Interpreter {
    handler = new Handler()

    execute(command, connectionType, tcpAddress) {
        let commandSerializer = new CommandSerializer()
        let byteMessage = commandSerializer.serialize(command,connectionType, tcpAddress)
        let responseByteArray

        if (command.runtimeName === Runtime.Nodejs)
        {
            // lazy receiver loading
            if (!Receiver) {
                Receiver = require('../receiver/Receiver')
            }
            responseByteArray = Receiver.sendCommand(byteMessage)

        }
        else {
            // lazy transmitter loading
            if (!Transmitter) {
                Transmitter = require('../transmitter/Transmitter')
            }
            responseByteArray = Transmitter.sendCommand(byteMessage)
        }
        return new CommandDeserializer(responseByteArray).deserialize()
    }

    process(byteArray) {
        let commandDeserializer = new CommandDeserializer(byteArray)
        let receivedCommand = commandDeserializer.deserialize()
        let responseCommand = this.handler.handleCommand(receivedCommand)
        let commandSerializer = new CommandSerializer()
        return commandSerializer.serialize(responseCommand, 0, "0.0.0.0:0")
    }
}

module.exports = Interpreter

Version data entries

8 entries across 4 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.3.0 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.3.0 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.2.0 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.2.0 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.1.14 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.1.14 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.1.13 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.1.13 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/interpreter/Interpreter.js