Code Monkey home page Code Monkey logo

Comments (2)

InfernoZeus avatar InfernoZeus commented on July 18, 2024

@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.

happy-python avatar happy-python commented on July 18, 2024

Hi, binary support is ok?

from websocket-nats.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.