diff --git a/ivette/package.json b/ivette/package.json index 130120d6846d99885098ac4c5c807add0d52561e..5c000eebf185db31c6cb64f668ae09dad48fbd1d 100644 --- a/ivette/package.json +++ b/ivette/package.json @@ -29,7 +29,6 @@ "@types/react": "^16", "@types/react-dom": "^16", "@types/react-virtualized": "^9.21.0", - "@types/zeromq": "^5.2.1", "@typescript-eslint/eslint-plugin": "", "@typescript-eslint/parser": "", "babel-loader": "^8.2.3", @@ -79,7 +78,6 @@ "react-virtualized": "^9.22.3", "react-window": "", "source-map-support": "^0.5.21", - "tippy.js": "6.3.7", - "zeromq": "^5.2.8" + "tippy.js": "6.3.7" } } diff --git a/ivette/src/frama-c/client_zmq.ts b/ivette/src/frama-c/client_zmq.ts deleted file mode 100644 index e66610de46cc555c1c555555398bd747303a7ad6..0000000000000000000000000000000000000000 --- a/ivette/src/frama-c/client_zmq.ts +++ /dev/null @@ -1,210 +0,0 @@ -/* ************************************************************************ */ -/* */ -/* This file is part of Frama-C. */ -/* */ -/* Copyright (C) 2007-2022 */ -/* CEA (Commissariat à l'énergie atomique et aux énergies */ -/* alternatives) */ -/* */ -/* you can redistribute it and/or modify it under the terms of the GNU */ -/* Lesser General Public License as published by the Free Software */ -/* Foundation, version 2.1. */ -/* */ -/* It is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* See the GNU Lesser General Public License version 2.1 */ -/* for more details (enclosed in the file licenses/LGPLv2.1). */ -/* */ -/* ************************************************************************ */ - -import * as ZMQ from 'zeromq'; -import { Debug } from 'dome'; -import { Client } from './client'; - -const D = new Debug('ZmqServer'); - -// -------------------------------------------------------------------------- -// --- Frama-C Server API -// -------------------------------------------------------------------------- - -class ZmqClient extends Client { - - queue: string[] = []; - zmqSocket: ZMQ.Socket | undefined; - zmqIsBusy = false; - - /** Server CLI */ - commandLine(sockaddr: string, params: string[]): string[] { - return ['-server-zmq', `ipc://${sockaddr}`, '-then'].concat(params); - } - - /** Connection */ - connect(sockaddr: string): void { - if (this.zmqSocket) { - this.zmqSocket.close(); - } - this.zmqSocket = new ZMQ.Socket('req'); - this.zmqIsBusy = false; - this.zmqSocket.connect(`ipc://${sockaddr}`); - this.zmqSocket.on('message', (msg: string[]) => this._receive(msg)); - } - - disconnect(): void { - this.zmqIsBusy = false; - this.queue = []; - if (this.zmqSocket) { - this.zmqSocket.close(); - this.zmqSocket = undefined; - } - } - - /** Send Request */ - send(kind: string, id: string, request: string, data: string): void { - if (this.zmqSocket) { - this.queue.push(kind, id, request, data); - this._flush(); - } - } - - /** Signal ON */ - sigOn(id: string): void { - if (this.zmqSocket) { - this.queue.push('SIGON', id); - this._flush(); - } - } - - /** Signal ON */ - sigOff(id: string): void { - if (this.zmqSocket) { - this.queue.push('SIGOFF', id); - this._flush(); - } - } - - /** Kill Request */ - kill(id: string): void { - if (this.zmqSocket) { - this.queue.push('KILL', id); - this._flush(); - } - } - - /** Polling */ - poll(): void { - if (this.zmqSocket && this.queue.length === 0) { - this.queue.push('POLL'); - } - this._flush(); - } - - /** Shutdown the server */ - shutdown(): void { - this.queue = []; - if (this.zmqSocket) { - this.queue.push('SHUTDOWN'); - this._flush(); - } - } - - // -------------------------------------------------------------------------- - // --- Low-Level Management - // -------------------------------------------------------------------------- - - _flush(): void { - const socket = this.zmqSocket; - if (socket) { - const cmds = this.queue; - if (cmds && !this.zmqIsBusy) { - try { - this.queue = []; - socket.send(cmds); - this.zmqIsBusy = true; - } catch (err) { - D.error('ZmqSocket', err); - this.zmqIsBusy = false; - } - } - } else { - this.queue = []; - } - } - - _receive(resp: string[]): void { - try { - this._decode(resp); - } catch (err) { - D.error('ZmqSocket', err); - } finally { - this.zmqIsBusy = false; - setImmediate(() => this._flush()); - } - } - - /* eslint-disable @typescript-eslint/indent */ - _decode(resp: string[]): void { - const shift = (): string => resp.shift() ?? ''; - while (resp.length) { - const cmd = shift(); - switch (cmd) { - case 'NONE': - break; - case 'DATA': - { - const rid = shift(); - const data = JSON.parse(shift()); - this.emitData(rid, data); - } - break; - case 'KILLED': - { - const rid = shift(); - this.emitKilled(rid); - } - break; - case 'ERROR': - { - const rid = shift(); - const msg = shift(); - this.emitError(rid, msg); - } - break; - case 'REJECTED': - { - const rid = shift(); - this.emitRejected(rid); - } - break; - case 'SIGNAL': - { - const rid = shift(); - this.emitSignal(rid); - } - break; - case 'WRONG': - { - const err = shift(); - D.error(`ZMQ Protocol Error: ${err}`); - } - break; - case 'CMDLINEON': - this.emitCmdLine(true); - break; - case 'CMDLINEOFF': - this.emitCmdLine(false); - break; - default: - D.error(`Unknown Response: ${cmd}`); - return; - } - } - } - -} - -export const client: Client = new ZmqClient(); - -// -------------------------------------------------------------------------- diff --git a/ivette/yarn.lock b/ivette/yarn.lock index 1970b9068a63a7e38c8b05fee219a7fe345951b9..68c29c52e021ed01caa40b93413da412b2c14ff5 100644 --- a/ivette/yarn.lock +++ b/ivette/yarn.lock @@ -2162,13 +2162,6 @@ dependencies: "@types/yargs-parser" "*" -"@types/zeromq@^5.2.1": - version "5.2.1" - resolved "https://registry.yarnpkg.com/@types/zeromq/-/zeromq-5.2.1.tgz#f4316166e90fbe01e25ec6a6efa84e9bc8f91314" - integrity sha512-B6fUT5ZanWEyKSmLLEA0K3zNPvVedrjL6LNZWAt1eOpNg0J2lw14ismPJeOrgPf3SzRuNhPReQWibHbnMrtRow== - dependencies: - "@types/node" "*" - "@typescript-eslint/eslint-plugin@": version "5.6.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.6.0.tgz#efd8668b3d6627c46ce722c2afe813928fe120a0" @@ -7103,11 +7096,6 @@ multicast-dns@^6.0.1: dns-packet "^1.3.1" thunky "^1.0.2" -nan@2.14.2: - version "2.14.2" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.2.tgz#f5376400695168f4cc694ac9393d0c9585eeea19" - integrity sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ== - nan@^2.12.1: version "2.15.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee" @@ -7173,11 +7161,6 @@ node-forge@^0.10.0: resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.10.0.tgz#32dea2afb3e9926f02ee5ce8794902691a676bf3" integrity sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA== -node-gyp-build@^4.2.3: - version "4.3.0" - resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.3.0.tgz#9f256b03e5826150be39c764bf51e993946d71a3" - integrity sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q== - node-libs-browser@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/node-libs-browser/-/node-libs-browser-2.2.1.tgz#b64f513d18338625f90346d27b0d235e631f6425" @@ -10118,11 +10101,3 @@ yauzl@^2.10.0: dependencies: buffer-crc32 "~0.2.3" fd-slicer "~1.1.0" - -zeromq@^5.2.8: - version "5.2.8" - resolved "https://registry.yarnpkg.com/zeromq/-/zeromq-5.2.8.tgz#94b0b85e4152e98b8bb163f1db4a34280d44d9d0" - integrity sha512-bXzsk7KOmgLSv1tC0Ms1VXBy90+Rz27ZYf27cLuldRYbpqYpuWJfxxHFhO710t22zgWBnmdUP0m3SKFpLI0u5g== - dependencies: - nan "2.14.2" - node-gyp-build "^4.2.3"