Unregister event listeners from websock.
Prevents possible memory and event notification leaks when tearing down connection and reestablishing a new one.
This commit is contained in:
@@ -197,6 +197,7 @@ var RFB;
|
||||
} else {
|
||||
this._fail("Server disconnected" + msg);
|
||||
}
|
||||
this._sock.off('close');
|
||||
}.bind(this));
|
||||
this._sock.on('error', function (e) {
|
||||
Util.Warn("WebSocket on-error event");
|
||||
@@ -239,6 +240,9 @@ var RFB;
|
||||
|
||||
disconnect: function () {
|
||||
this._updateState('disconnect', 'Disconnecting');
|
||||
this._sock.off('error');
|
||||
this._sock.off('message');
|
||||
this._sock.off('open');
|
||||
},
|
||||
|
||||
sendPassword: function (passwd) {
|
||||
|
||||
@@ -200,6 +200,10 @@ function Websock() {
|
||||
},
|
||||
|
||||
// Event Handlers
|
||||
off: function (evt) {
|
||||
this._eventHandlers[evt] = function () {};
|
||||
},
|
||||
|
||||
on: function (evt, handler) {
|
||||
this._eventHandlers[evt] = handler;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user