Merge pull request #66 from h3poteto/fix/stop-handle

fix: Remove error handler after close connection and set connection flag
This commit is contained in:
AkiraFukushima 2019-08-30 22:46:08 +09:00 committed by GitHub
commit da79a659d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,6 +66,7 @@ export default class WebSocket extends EventEmitter {
* Stop current connection.
*/
public stop() {
this._connectionClosed = true
this._resetConnection()
this._resetRetryParams()
}
@ -75,8 +76,8 @@ export default class WebSocket extends EventEmitter {
*/
private _resetConnection() {
if (this._client) {
this._client.removeAllListeners()
this._client.close(1000)
this._client.removeAllListeners()
this._client = null
}