Kill server process

remixd
ioedeveloper 5 years ago
parent aaae27f29a
commit 9113c83e60
  1. 2
      lib/src/services/remixdClient.d.ts
  2. 4
      lib/src/services/remixdClient.js
  3. 2
      lib/src/websocket.d.ts
  4. 14
      lib/src/websocket.js
  5. 37
      package-lock.json
  6. 3
      package.json
  7. 2
      src/services/remixdClient.ts
  8. 16
      src/websocket.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;

@ -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);

@ -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;
}

@ -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;
}());

37
package-lock.json generated

@ -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",

@ -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",

@ -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')

@ -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()
}
}

Loading…
Cancel
Save