Sha256: 6879cf83a2b3dd57321bb0eb9d81d8126747f098283b031bf4176c1e30119735

Contents?: true

Size: 1.16 KB

Versions: 12

Compression:

Stored size: 1.16 KB

Contents

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

let Transmitter

class Interpreter {
    handler = new Handler()

    execute(command, connectionType, tcpAddress) {
        let commandEncoder = new CommandEncoder()
        let byteMessage = commandEncoder.encode(command,connectionType, tcpAddress)
        let responseByteArray

        if (command.runtimeName === Runtime.Nodejs)
        {
            return this.process(byteMessage)
        }
        else {
            // lazy transmitter loading
            if (!Transmitter) {
                Transmitter = require('../transmitter/Transmitter')
            }
            responseByteArray = Transmitter.sendCommand(byteMessage)
            return new CommandDecoder(responseByteArray).decode()
        }
    }

    process(byteArray) {
        let decoder = new CommandDecoder(byteArray)
        let command = decoder.decode()
        return this.handler.handleCommand(command)
    }
}

module.exports = Interpreter

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.1.12 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.1.11 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.1.10 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.1.9 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.1.8 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.1.7 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.1.6 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.1.5 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.1.4 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.1.3 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.1.2 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/interpreter/Interpreter.js
javonet-ruby-sdk-2.1.1 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/interpreter/Interpreter.js