Move disconnect actions to a separate funciton

Done in order to be consistent with connect() and to separate state
actions from connection actions.
This commit is contained in:
Samuel Mannehed 2016-11-08 16:07:47 +01:00
parent 376864d6d1
commit c4b274ebb8
1 changed files with 9 additions and 4 deletions

View File

@ -385,6 +385,14 @@
Util.Debug("<< RFB.connect"); Util.Debug("<< RFB.connect");
}, },
_disconnect: function () {
Util.Debug(">> RFB.disconnect");
this._cleanup();
this._sock.close();
this._print_stats();
Util.Debug("<< RFB.disconnect");
},
_init_vars: function () { _init_vars: function () {
// reset state // reset state
this._FBU.rects = 0; this._FBU.rects = 0;
@ -503,15 +511,12 @@
break; break;
case 'disconnecting': case 'disconnecting':
this._cleanup(); this._disconnect();
this._sock.close(); // transitions to 'disconnected'
this._disconnTimer = setTimeout(function () { this._disconnTimer = setTimeout(function () {
this._rfb_disconnect_reason = "Disconnect timeout"; this._rfb_disconnect_reason = "Disconnect timeout";
this._updateConnectionState('disconnected'); this._updateConnectionState('disconnected');
}.bind(this), this._disconnectTimeout * 1000); }.bind(this), this._disconnectTimeout * 1000);
this._print_stats();
break; break;
default: default: