Skip to content

Commit c17e189

Browse files
committed
Merge pull request PatrickJS#45 from vanishs/master
support arraybuffer
2 parents d1b2210 + fac7d45 commit c17e189

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

angular-websocket.js

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

44-
// this.binaryType = '';
4544
// this.extensions = '';
4645
// this.bufferedAmount = 0;
4746
// this.trasnmitting = false;
@@ -54,6 +53,7 @@
5453
this.initialTimeout = options && options.initialTimeout || 500; // 500ms
5554
this.maxTimeout = options && options.maxTimeout || 5 * 60 * 1000; // 5 minutes
5655
this.reconnectIfNotNormalClose = options && options.reconnectIfNotNormalClose || false;
56+
this.binaryType = options && options.binaryType || 'blob';
5757

5858
this._reconnectAttempts = 0;
5959
this.sendQueue = [];
@@ -113,6 +113,7 @@
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;
116117
}
117118
};
118119

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

123124
this.socket.send(
124-
isString(data.message) ? data.message : JSON.stringify(data.message)
125+
data.message
125126
);
126127
data.deferred.resolve();
127128
}

dist/angular-websocket.js

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

44-
// this.binaryType = '';
4544
// this.extensions = '';
4645
// this.bufferedAmount = 0;
4746
// this.trasnmitting = false;
@@ -54,6 +53,7 @@
5453
this.initialTimeout = options && options.initialTimeout || 500; // 500ms
5554
this.maxTimeout = options && options.maxTimeout || 5 * 60 * 1000; // 5 minutes
5655
this.reconnectIfNotNormalClose = options && options.reconnectIfNotNormalClose || false;
56+
this.binaryType = options && options.binaryType || 'blob';
5757

5858
this._reconnectAttempts = 0;
5959
this.sendQueue = [];
@@ -113,6 +113,7 @@
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;
116117
}
117118
};
118119

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

123124
this.socket.send(
124-
isString(data.message) ? data.message : JSON.stringify(data.message)
125+
data.message
125126
);
126127
data.deferred.resolve();
127128
}

0 commit comments

Comments
 (0)