From 71de0912a92628f79527820c0e246833b520feab Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 1 Jun 2020 11:12:37 +0000 Subject: [PATCH] Kill server process --- lib/src/services/remixdClient.d.ts | 2 +- lib/src/services/remixdClient.js | 4 ++-- lib/src/websocket.d.ts | 2 -- lib/src/websocket.js | 14 +++-------- package-lock.json | 37 ++++++++++++++++++++++++------ package.json | 3 ++- src/services/remixdClient.ts | 2 +- src/websocket.ts | 16 +++---------- 8 files changed, 42 insertions(+), 38 deletions(-) diff --git a/lib/src/services/remixdClient.d.ts b/lib/src/services/remixdClient.d.ts index 77ad9b4353..016ddd9fcc 100644 --- a/lib/src/services/remixdClient.d.ts +++ b/lib/src/services/remixdClient.d.ts @@ -1,5 +1,5 @@ import WebSocket from '../websocket'; -import { PluginClient } from '@remixproject/plugin-ws'; +import { PluginClient } from '@remixproject/plugin'; export default class RemixdClient extends PluginClient { trackDownStreamUpdate: { [key: string]: string; diff --git a/lib/src/services/remixdClient.js b/lib/src/services/remixdClient.js index 4c16f20362..194c819e43 100644 --- a/lib/src/services/remixdClient.js +++ b/lib/src/services/remixdClient.js @@ -13,7 +13,7 @@ var __extends = (this && this.__extends) || (function () { }; })(); Object.defineProperty(exports, "__esModule", { value: true }); -var plugin_ws_1 = require("@remixproject/plugin-ws"); +var plugin_1 = require("@remixproject/plugin"); var utils = require('../utils'); var isbinaryfile = require('isbinaryfile'); var fs = require('fs-extra'); @@ -142,7 +142,7 @@ var RemixdClient = /** @class */ (function (_super) { cb(null, fs.statSync(path).isFile()); }; return RemixdClient; -}(plugin_ws_1.PluginClient)); +}(plugin_1.PluginClient)); exports.default = RemixdClient; function isRealPath(path, cb) { var realPath = fs.realpathSync(path); diff --git a/lib/src/websocket.d.ts b/lib/src/websocket.d.ts index 56127edcf1..ba7774563c 100644 --- a/lib/src/websocket.d.ts +++ b/lib/src/websocket.d.ts @@ -9,12 +9,10 @@ export default class WebSocket { }; server: http.Server; wsServer: WS.Server; - connection: WS; remixdClient: RemixdClient; constructor(port: number, opt: { [key: string]: string; }, remixdClient: RemixdClient); start(callback?: Function): void; - send(data: any): void; close(): void; } diff --git a/lib/src/websocket.js b/lib/src/websocket.js index f1135cb60c..5a56511900 100644 --- a/lib/src/websocket.js +++ b/lib/src/websocket.js @@ -22,22 +22,14 @@ var WebSocket = /** @class */ (function () { }); this.wsServer = new WS.Server({ server: this.server }); this.wsServer.on('connection', function connection(ws) { - obj.connection = ws; - var client = buildWebsocketClient(obj.connection, obj.remixdClient); + var client = buildWebsocketClient(ws, obj.remixdClient); if (callback) callback(client); }); }; - WebSocket.prototype.send = function (data) { - this.connection.send(data); - }; WebSocket.prototype.close = function () { - if (this.connection) { - this.connection.close(); - } - if (this.server) { - this.server.close(); - } + console.log('this.server: ', this.server); + this.server.close(); }; return WebSocket; }()); diff --git a/package-lock.json b/package-lock.json index b76cb6b48b..6c1ba00a94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -83,16 +83,34 @@ } }, "@remixproject/plugin": { - "version": "0.2.0-alpha.1", - "resolved": "https://registry.npmjs.org/@remixproject/plugin/-/plugin-0.2.0-alpha.1.tgz", - "integrity": "sha512-nPZgtwrvk3Ib81Aa+/rJxUxdWwCIF8aNYZxCG5QvfQCTf1nwRP8vdtvRrQOjTQncSYFHLlyNUWCVFcLcNj6AdA==" + "version": "0.3.0-alpha.3", + "resolved": "https://registry.npmjs.org/@remixproject/plugin/-/plugin-0.3.0-alpha.3.tgz", + "integrity": "sha512-8Vd0/zj/ZxXIYrC+p9DZdi/ZOMeZEvvIJOavxNeiDC2H2KFc0Uwaw1y4x3JMeLGd6LnFZq54MYgscDpYJvnTHw==", + "requires": { + "@types/node": "^13.13.4", + "events": "^3.0.0" + }, + "dependencies": { + "@types/node": { + "version": "13.13.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.9.tgz", + "integrity": "sha512-EPZBIGed5gNnfWCiwEIwTE2Jdg4813odnG8iNPMQGrqVxrI+wL68SPtPeCX+ZxGBaA6pKAVc6jaKgP/Q0QzfdQ==" + } + } }, "@remixproject/plugin-ws": { - "version": "0.2.0-alpha.1", - "resolved": "https://registry.npmjs.org/@remixproject/plugin-ws/-/plugin-ws-0.2.0-alpha.1.tgz", - "integrity": "sha512-j5m6jKsTJpgog3gdZ30dpqMz2YopHZP4PNi+eAfJKEyMMMFiqb5tIbU8QZ8TcDtTy/wlB7/pH5PhvvVIdkQWFQ==", + "version": "0.3.0-alpha.1", + "resolved": "https://registry.npmjs.org/@remixproject/plugin-ws/-/plugin-ws-0.3.0-alpha.1.tgz", + "integrity": "sha512-e6d6Bzf8Pdz3PID8mCpKifBjAVaaIk3+0/iDm6tN3GR5j+iELpq/ddZF6UGAT9kAliOdmNDDnBTSN7Fg1/9sLw==", "requires": { - "@remixproject/plugin": "0.2.0-alpha.1" + "@remixproject/plugin": "0.3.0-alpha.1" + }, + "dependencies": { + "@remixproject/plugin": { + "version": "0.3.0-alpha.1", + "resolved": "https://registry.npmjs.org/@remixproject/plugin/-/plugin-0.3.0-alpha.1.tgz", + "integrity": "sha512-9ImF6Zrk58jSMabiBnn00dfjCma6Dr1bzlr4Y7DpK0+cukagPgt5GI1Cx6FxRA7CKzHj7OAxl4HmtlieIrQTyA==" + } } }, "@sindresorhus/is": { @@ -1239,6 +1257,11 @@ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, + "events": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.1.0.tgz", + "integrity": "sha512-Rv+u8MLHNOdMjTAFeT3nCjHn2aGlx435FP/sDHNaRhDEMwyI/aB22Kj2qIN8R0cw3z28psEQLYwxVKLsKrMgWg==" + }, "expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", diff --git a/package.json b/package.json index 2439eedf99..de235610ad 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,8 @@ }, "homepage": "https://github.com/ethereum/remixd#readme", "dependencies": { - "@remixproject/plugin-ws": "^0.2.0-alpha.1", + "@remixproject/plugin": "^0.3.0-alpha.3", + "@remixproject/plugin-ws": "^0.3.0-alpha.1", "chalk": "^4.0.0", "chokidar": "^2.0.2", "commander": "^2.20.3", diff --git a/src/services/remixdClient.ts b/src/services/remixdClient.ts index 247f70f5a8..7f1dbf9a00 100644 --- a/src/services/remixdClient.ts +++ b/src/services/remixdClient.ts @@ -1,5 +1,5 @@ import WebSocket from '../websocket' -import { PluginClient } from '@remixproject/plugin-ws' +import { PluginClient } from '@remixproject/plugin' const utils = require('../utils') const isbinaryfile = require('isbinaryfile') diff --git a/src/websocket.ts b/src/websocket.ts index 1a287c50f9..965395571a 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -10,7 +10,6 @@ export default class WebSocket { } server: http.Server wsServer: WS.Server - connection: WS remixdClient: RemixdClient constructor (port: number, opt: { @@ -36,23 +35,14 @@ export default class WebSocket { }) this.wsServer = new WS.Server({ server: this.server }) this.wsServer.on('connection', function connection(ws) { - obj.connection = ws - const client = buildWebsocketClient(obj.connection, obj.remixdClient) + const client = buildWebsocketClient(ws, obj.remixdClient) if(callback) callback(client) }) } - send (data: any) { - this.connection.send(data) - } - close () { - if (this.connection) { - this.connection.close() - } - if (this.server) { - this.server.close() - } + console.log('this.server: ', this.server) + this.server.close() } }