Coder Social home page Coder Social logo

Allow simpler direct data access about ng-websocket HOT 4 OPEN

wilk avatar wilk commented on September 17, 2024
Allow simpler direct data access

from ng-websocket.

Comments (4)

wilk avatar wilk commented on September 17, 2024

JSON is good for sending complex data through the network.
What's the alternative for non-JSON encoded data?
Which is the encoding that ng-websocket needs to send data with the disabled JSON flag?

from ng-websocket.

r1chardj0n3s avatar r1chardj0n3s commented on September 17, 2024

Hi, I agree JSON is a good idea, but in my use case the websocket is a terminal connection to a virtual machine serial console - raw terminal data :)

from ng-websocket.

wilk avatar wilk commented on September 17, 2024

Ok but how do you send complex data through the network?

For instance, this is how ng-websocket sends data via websocket:

var ws = new WebSocket(url),
      complexData = {a:10, b:'hello', c:{ca:20, cb: 'world'}, d: ['a', 'b', 10, {da: 15}]};

ws.send(JSON.stringify(complexData));

What's your way?

from ng-websocket.

r1chardj0n3s avatar r1chardj0n3s commented on September 17, 2024

My current use-case is just the console connection, like so:

      var socket = $websocket.$new(scope.connection.url, ['binary', 'base64']);
      ...
      term.on('data', function (data) {
        socket.$$ws.send(data);
      });
      socket.$on('$message', function (message) {
        if (message instanceof Blob) {
          var f = new FileReader();
          f.onload = function () {term.write(f.result); };
          f.readAsText(message);
        } else {
          term.write(message);
        }
      });

(from https://github.com/r1chardj0n3s/angboard/blob/master/app/scripts/directives/console.js)

from ng-websocket.

Related Issues (20)

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.