|
41 | 41 | this.url = url || 'Missing URL';
|
42 | 42 | this.ssl = /(wss)/i.test(this.url);
|
43 | 43 |
|
44 | | - // this.binaryType = ''; |
45 | 44 | // this.extensions = '';
|
46 | 45 | // this.bufferedAmount = 0;
|
47 | 46 | // this.trasnmitting = false;
|
|
54 | 53 | this.initialTimeout = options && options.initialTimeout || 500; // 500ms
|
55 | 54 | this.maxTimeout = options && options.maxTimeout || 5 * 60 * 1000; // 5 minutes
|
56 | 55 | this.reconnectIfNotNormalClose = options && options.reconnectIfNotNormalClose || false;
|
| 56 | + this.binaryType = options && options.binaryType || 'blob'; |
57 | 57 |
|
58 | 58 | this._reconnectAttempts = 0;
|
59 | 59 | this.sendQueue = [];
|
|
109 | 109 | $WebSocket.prototype._connect = function _connect(force) {
|
110 | 110 | if (force || !this.socket || this.socket.readyState !== this._readyStateConstants.OPEN) {
|
111 | 111 | this.socket = $websocketBackend.create(this.url, this.protocols);
|
| 112 | + this.socket.binaryType = this.binaryType; |
112 | 113 | this.socket.onmessage = angular.bind(this, this._onMessageHandler);
|
113 | 114 | this.socket.onopen = angular.bind(this, this._onOpenHandler);
|
114 | 115 | this.socket.onerror = angular.bind(this, this._onErrorHandler);
|
|
121 | 122 | var data = this.sendQueue.shift();
|
122 | 123 |
|
123 | 124 | this.socket.send(
|
124 | | - isString(data.message) ? data.message : JSON.stringify(data.message) |
| 125 | + data.message |
125 | 126 | );
|
126 | 127 | data.deferred.resolve();
|
127 | 128 | }
|
|
0 commit comments