Skip to content

Commit 75fda21

Browse files
committed
chore: dist
1 parent fdfea1f commit 75fda21

7 files changed

+33834
-51
lines changed

angular-websocket.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
this.url = url || 'Missing URL';
4242
this.ssl = /(wss)/i.test(this.url);
4343

44+
// this.binaryType = '';
4445
// this.extensions = '';
4546
// this.bufferedAmount = 0;
4647
// this.trasnmitting = false;
@@ -53,7 +54,6 @@
5354
this.initialTimeout = options && options.initialTimeout || 500; // 500ms
5455
this.maxTimeout = options && options.maxTimeout || 5 * 60 * 1000; // 5 minutes
5556
this.reconnectIfNotNormalClose = options && options.reconnectIfNotNormalClose || false;
56-
this.binaryType = options && options.binaryType || 'blob';
5757

5858
this._reconnectAttempts = 0;
5959
this.sendQueue = [];
@@ -113,7 +113,6 @@
113113
this.socket.onopen = angular.bind(this, this._onOpenHandler);
114114
this.socket.onerror = angular.bind(this, this._onErrorHandler);
115115
this.socket.onclose = angular.bind(this, this._onCloseHandler);
116-
this.socket.binaryType = this.binaryType;
117116
}
118117
};
119118

@@ -122,7 +121,7 @@
122121
var data = this.sendQueue.shift();
123122

124123
this.socket.send(
125-
data.message
124+
isString(data.message) ? data.message : JSON.stringify(data.message)
126125
);
127126
data.deferred.resolve();
128127
}
@@ -186,14 +185,30 @@
186185
};
187186

188187
$WebSocket.prototype._onCloseHandler = function _onCloseHandler(event) {
189-
this.notifyCloseCallbacks(event);
188+
var self = this;
189+
if (self.useApplyAsync) {
190+
self.scope.$applyAsync(function() {
191+
self.notifyCloseCallbacks(event);
192+
});
193+
} else {
194+
self.notifyCloseCallbacks(event);
195+
self.safeDigest(autoApply);
196+
}
190197
if ((this.reconnectIfNotNormalClose && event.code !== this._normalCloseCode) || this._reconnectableStatusCodes.indexOf(event.code) > -1) {
191198
this.reconnect();
192199
}
193200
};
194201

195202
$WebSocket.prototype._onErrorHandler = function _onErrorHandler(event) {
196-
this.notifyErrorCallbacks(event);
203+
var self = this;
204+
if (self.useApplyAsync) {
205+
self.scope.$applyAsync(function() {
206+
self.notifyErrorCallbacks(event);
207+
});
208+
} else {
209+
self.notifyErrorCallbacks(event);
210+
self.safeDigest(autoApply);
211+
}
197212
};
198213

199214
$WebSocket.prototype._onMessageHandler = function _onMessageHandler(message) {
@@ -346,7 +361,7 @@
346361
}
347362

348363
// CommonJS
349-
if (typeof exports === 'object' && typeof require === 'function') {
364+
if (typeof exports === 'object' && require) {
350365
try {
351366
ws = require('ws');
352367
Socket = (ws.Client || ws.client || ws);

angular-websocket.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)