sy_node_rpc
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -21,2 +21,3 @@ const BaseSocket = require('./base_socket'); | ||
this.client = null; | ||
this.options = options; | ||
@@ -41,5 +42,35 @@ if (options.socket) { | ||
this.client.on('error', this._errorHandler.bind(this)); | ||
this.client.on('timeout', this._timeoutHandler.bind(this)); | ||
} | ||
reconnect() { | ||
if (this.closed) { | ||
throw Error('socket already destroyed'); | ||
} | ||
if (!this.client.destroyed) { | ||
throw Error('socket is connecting'); | ||
} | ||
if (this.options.socket) { | ||
throw Error('only client can be reconnected'); | ||
} | ||
if (!this.options.host || !this.options.port) { | ||
throw Error('invalid options'); | ||
} | ||
this.client = new net.Socket(); | ||
this.client.connect({ | ||
host: this.options.host, | ||
port: this.options.port | ||
}); | ||
this.remoteAddress = this.client.remoteAddress; | ||
this.client.on('connect', this._connectHandler.bind(this)); | ||
this.client.on('close', this._closeHandler.bind(this)); | ||
this.client.on('data', this._dataHandler.bind(this)); | ||
this.client.on('error', this._errorHandler.bind(this)); | ||
this.client.on('timeout', this._timeoutHandler.bind(this)); | ||
} | ||
/** | ||
@@ -200,2 +231,7 @@ * 发起rpc 请求 | ||
}; | ||
_timeoutHandler() { | ||
this.emit('timeout'); | ||
} | ||
} | ||
@@ -202,0 +238,0 @@ |
{ | ||
"name": "sy_node_rpc", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"engines": { | ||
"node": ">=8.0.0" | ||
"node": ">=7.6" | ||
}, | ||
@@ -7,0 +7,0 @@ "private": false, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
66328
0
347