Skip to content

Commit 71bbfd8

Browse files
author
Christian Jeschke
committed
allowing garbage collector to clean WebSocket instances
this should avoid memory leaks if the webserver is not available added a test on reconnects to the howToTest package
1 parent 3a191cf commit 71bbfd8

6 files changed

+30
-6
lines changed

dist/angular-websocket.js

+7
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@
142142
};
143143

144144
$WebSocket.prototype._connect = function _connect(force) {
145+
if (this.socket) {
146+
this.socket.onmessage = null;
147+
this.socket.onopen = null;
148+
this.socket.onerror = null;
149+
this.socket.onclose = null;
150+
this.socket.close();
151+
}
145152
if (force || !this.socket || this.socket.readyState !== this._readyStateConstants.OPEN) {
146153
this.socket = $websocketBackend.create(this.url, this.protocols);
147154
this.socket.onmessage = _angular2.default.bind(this, this._onMessageHandler);

dist/angular-websocket.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)