Comments (2)
@mmardinian Not sure if you're still interested, but I'm adding this just as much for other's who might have the same problem.
I couldn't get this working without some changes. The following patch to dist/websocket-nats.js let me receive the binary buffer when setting the encoding to buffer:
$ diff websocket-nats.js.orig websocket-nats.js
863a864
> client.payload.data = mbuf.slice(0, client.payload.size);
865a867
> client.payload.data = client.inbound.slice(0, client.payload.size);
936,941c938,947
< var msg = this.payload.msg;
< if (this.options.json) {
< try {
< msg = JSON.parse(new Buffer(this.payload.msg, this.options.encoding).toString());
< } catch (e) {
< msg = e;
---
> if (this.options.encoding == 'binary') {
> var msg = this.payload.data;
> } else {
> var msg = this.payload.msg;
> if (this.options.json) {
> try {
> msg = JSON.parse(new Buffer(this.payload.msg, this.options.encoding).toString());
> } catch (e) {
> msg = e;
> }
I haven't managed to test it with multi-chunk payloads though. (I don't know when that occurs, so difficult to trigger...)
from websocket-nats.
Hi, binary support is ok?
from websocket-nats.
Related Issues (13)
- node-nats has new update for token authn HOT 2
- websocket-nats is not working as expected with webpack version 2 and above
- Using websocket-nats in NodeJS HOT 1
- Does this client support NATS streaming protocol? HOT 2
- Then recent nats-server already support websocket
- websocket-nats halt firefox,seems a infinite loop HOT 3
- websocket connect with hostname and pathname HOT 1
- websocket-nats can't publish binary message(Uint8Array) HOT 4
- output a unuglify and not minimize js file for dev HOT 2
- Using setImmediate HOT 3
- Bad decoding for languages other than English
- TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object. HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from websocket-nats.