Comments (4)
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.
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.
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.
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)
- Browser support & fallback? HOT 1
- Protocol Chrome error HOT 9
- how should i construct a socket to ws://localhost:12345/abc/ac ? HOT 1
- Exponential number of reconnects HOT 4
- Loose access to $scope HOT 2
- ERR_CONNECTION_REFUSED HOT 4
- Updating the angular version? HOT 3
- update url in reconnect HOT 3
- ws socket instance HOT 2
- server reject vs. losing connection HOT 2
- Is it possible to send credentials when connecting to the web-socket?
- $on custom events not working properly HOT 1
- onclose does not pass event HOT 1
- $get return undefined
- Project maintained ? HOT 1
- Socket $destroy HOT 1
- How does this project compare to https://github.com/AngularClass/angular-websocket
- 60 seconds of Timeout period, How to decrease it?
- Connect with headers
- Cannot reopen websocket after calling $close() HOT 4
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 ng-websocket.