Kill server process

pull/3094/head
ioedeveloper 5 years ago
parent 5789783327
commit 71de0912a9
  1. 2
      lib/src/services/remixdClient.d.ts
  2. 4
      lib/src/services/remixdClient.js
  3. 2
      lib/src/websocket.d.ts
  4. 12
      lib/src/websocket.js
  5. 37
      package-lock.json
  6. 3
      package.json
  7. 2
      src/services/remixdClient.ts
  8. 14
      src/websocket.ts

@ -1,5 +1,5 @@
import WebSocket from '../websocket'; import WebSocket from '../websocket';
import { PluginClient } from '@remixproject/plugin-ws'; import { PluginClient } from '@remixproject/plugin';
export default class RemixdClient extends PluginClient { export default class RemixdClient extends PluginClient {
trackDownStreamUpdate: { trackDownStreamUpdate: {
[key: string]: string; [key: string]: string;

@ -13,7 +13,7 @@ var __extends = (this && this.__extends) || (function () {
}; };
})(); })();
Object.defineProperty(exports, "__esModule", { value: true }); 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 utils = require('../utils');
var isbinaryfile = require('isbinaryfile'); var isbinaryfile = require('isbinaryfile');
var fs = require('fs-extra'); var fs = require('fs-extra');
@ -142,7 +142,7 @@ var RemixdClient = /** @class */ (function (_super) {
cb(null, fs.statSync(path).isFile()); cb(null, fs.statSync(path).isFile());
}; };
return RemixdClient; return RemixdClient;
}(plugin_ws_1.PluginClient)); }(plugin_1.PluginClient));
exports.default = RemixdClient; exports.default = RemixdClient;
function isRealPath(path, cb) { function isRealPath(path, cb) {
var realPath = fs.realpathSync(path); var realPath = fs.realpathSync(path);

@ -9,12 +9,10 @@ export default class WebSocket {
}; };
server: http.Server; server: http.Server;
wsServer: WS.Server; wsServer: WS.Server;
connection: WS;
remixdClient: RemixdClient; remixdClient: RemixdClient;
constructor(port: number, opt: { constructor(port: number, opt: {
[key: string]: string; [key: string]: string;
}, remixdClient: RemixdClient); }, remixdClient: RemixdClient);
start(callback?: Function): void; start(callback?: Function): void;
send(data: any): void;
close(): void; close(): void;
} }

@ -22,22 +22,14 @@ var WebSocket = /** @class */ (function () {
}); });
this.wsServer = new WS.Server({ server: this.server }); this.wsServer = new WS.Server({ server: this.server });
this.wsServer.on('connection', function connection(ws) { this.wsServer.on('connection', function connection(ws) {
obj.connection = ws; var client = buildWebsocketClient(ws, obj.remixdClient);
var client = buildWebsocketClient(obj.connection, obj.remixdClient);
if (callback) if (callback)
callback(client); callback(client);
}); });
}; };
WebSocket.prototype.send = function (data) {
this.connection.send(data);
};
WebSocket.prototype.close = function () { WebSocket.prototype.close = function () {
if (this.connection) { console.log('this.server: ', this.server);
this.connection.close();
}
if (this.server) {
this.server.close(); this.server.close();
}
}; };
return WebSocket; return WebSocket;
}()); }());

37
package-lock.json generated

@ -83,16 +83,34 @@
} }
}, },
"@remixproject/plugin": { "@remixproject/plugin": {
"version": "0.2.0-alpha.1", "version": "0.3.0-alpha.3",
"resolved": "https://registry.npmjs.org/@remixproject/plugin/-/plugin-0.2.0-alpha.1.tgz", "resolved": "https://registry.npmjs.org/@remixproject/plugin/-/plugin-0.3.0-alpha.3.tgz",
"integrity": "sha512-nPZgtwrvk3Ib81Aa+/rJxUxdWwCIF8aNYZxCG5QvfQCTf1nwRP8vdtvRrQOjTQncSYFHLlyNUWCVFcLcNj6AdA==" "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": { "@remixproject/plugin-ws": {
"version": "0.2.0-alpha.1", "version": "0.3.0-alpha.1",
"resolved": "https://registry.npmjs.org/@remixproject/plugin-ws/-/plugin-ws-0.2.0-alpha.1.tgz", "resolved": "https://registry.npmjs.org/@remixproject/plugin-ws/-/plugin-ws-0.3.0-alpha.1.tgz",
"integrity": "sha512-j5m6jKsTJpgog3gdZ30dpqMz2YopHZP4PNi+eAfJKEyMMMFiqb5tIbU8QZ8TcDtTy/wlB7/pH5PhvvVIdkQWFQ==", "integrity": "sha512-e6d6Bzf8Pdz3PID8mCpKifBjAVaaIk3+0/iDm6tN3GR5j+iELpq/ddZF6UGAT9kAliOdmNDDnBTSN7Fg1/9sLw==",
"requires": { "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": { "@sindresorhus/is": {
@ -1239,6 +1257,11 @@
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
"dev": true "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": { "expand-brackets": {
"version": "2.1.4", "version": "2.1.4",
"resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz",

@ -31,7 +31,8 @@
}, },
"homepage": "https://github.com/ethereum/remixd#readme", "homepage": "https://github.com/ethereum/remixd#readme",
"dependencies": { "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", "chalk": "^4.0.0",
"chokidar": "^2.0.2", "chokidar": "^2.0.2",
"commander": "^2.20.3", "commander": "^2.20.3",

@ -1,5 +1,5 @@
import WebSocket from '../websocket' import WebSocket from '../websocket'
import { PluginClient } from '@remixproject/plugin-ws' import { PluginClient } from '@remixproject/plugin'
const utils = require('../utils') const utils = require('../utils')
const isbinaryfile = require('isbinaryfile') const isbinaryfile = require('isbinaryfile')

@ -10,7 +10,6 @@ export default class WebSocket {
} }
server: http.Server server: http.Server
wsServer: WS.Server wsServer: WS.Server
connection: WS
remixdClient: RemixdClient remixdClient: RemixdClient
constructor (port: number, opt: { constructor (port: number, opt: {
@ -36,23 +35,14 @@ export default class WebSocket {
}) })
this.wsServer = new WS.Server({ server: this.server }) this.wsServer = new WS.Server({ server: this.server })
this.wsServer.on('connection', function connection(ws) { this.wsServer.on('connection', function connection(ws) {
obj.connection = ws const client = buildWebsocketClient(ws, obj.remixdClient)
const client = buildWebsocketClient(obj.connection, obj.remixdClient)
if(callback) callback(client) if(callback) callback(client)
}) })
} }
send (data: any) {
this.connection.send(data)
}
close () { close () {
if (this.connection) { console.log('this.server: ', this.server)
this.connection.close()
}
if (this.server) {
this.server.close() this.server.close()
} }
} }
}

Loading…
Cancel
Save