Skip to content

Commit d92fe86

Browse files
Amgad NaiemPatrickJS
Amgad Naiem
authored andcommitted
fixed arraybuffer data type
1 parent 56c2534 commit d92fe86

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

angular-websocket.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
this.initialTimeout = options && options.initialTimeout || 500; // 500ms
5555
this.maxTimeout = options && options.maxTimeout || 5 * 60 * 1000; // 5 minutes
5656
this.reconnectIfNotNormalClose = options && options.reconnectIfNotNormalClose || false;
57+
this.binaryType = options && options.binaryType || 'blob';
5758

5859
this._reconnectAttempts = 0;
5960
this.sendQueue = [];
@@ -113,6 +114,7 @@
113114
this.socket.onopen = angular.bind(this, this._onOpenHandler);
114115
this.socket.onerror = angular.bind(this, this._onErrorHandler);
115116
this.socket.onclose = angular.bind(this, this._onCloseHandler);
117+
this.socket.binaryType = this.binaryType;
116118
}
117119
};
118120

@@ -121,7 +123,7 @@
121123
var data = this.sendQueue.shift();
122124

123125
this.socket.send(
124-
isString(data.message) ? data.message : JSON.stringify(data.message)
126+
isString(data.message) || this.binaryType != "blob" ? data.message : JSON.stringify(data.message)
125127
);
126128
data.deferred.resolve();
127129
}

dist/angular-websocket.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
this.initialTimeout = options && options.initialTimeout || 500; // 500ms
5555
this.maxTimeout = options && options.maxTimeout || 5 * 60 * 1000; // 5 minutes
5656
this.reconnectIfNotNormalClose = options && options.reconnectIfNotNormalClose || false;
57+
this.binaryType = options && options.binaryType || 'blob';
5758

5859
this._reconnectAttempts = 0;
5960
this.sendQueue = [];
@@ -113,6 +114,7 @@
113114
this.socket.onopen = angular.bind(this, this._onOpenHandler);
114115
this.socket.onerror = angular.bind(this, this._onErrorHandler);
115116
this.socket.onclose = angular.bind(this, this._onCloseHandler);
117+
this.socket.binaryType = this.binaryType;
116118
}
117119
};
118120

@@ -121,7 +123,7 @@
121123
var data = this.sendQueue.shift();
122124

123125
this.socket.send(
124-
isString(data.message) ? data.message : JSON.stringify(data.message)
126+
isString(data.message) || this.binaryType != "blob" ? data.message : JSON.stringify(data.message)
125127
);
126128
data.deferred.resolve();
127129
}

0 commit comments

Comments
 (0)