alpacahq / alpaca-ts

A TypeScript Node.js library for the https://alpaca.markets REST API and WebSocket streams.
ISC License
156 stars 41 forks source link

AlpacaStream support for ArrayBuffer formatted binary messages #75

Closed samwilkins333 closed 3 years ago

samwilkins333 commented 3 years ago

Hi there,

In a React Native project, I ran into a JSON.parse error on instantiating an AlpacaStream because (in this context) the default binary data type for WebSocket seems to be ArrayBuffer rather than Blob. This might be fixable by instead setting this.connection.binaryType = 'blob'; right after instantiating the WebSocket, but I offer this addition for any use cases where ArrayBuffer might be needed.

For reference, the decoding of the ArrayBuffer was taken from here.

117 commented 3 years ago

Nice catch. 🙂

117 commented 3 years ago

Now available in the latest public version 6.2.4.