I got this as below from backend developer:
session.publish('com.test.temp', [
temp,
humidity,
componentId,
componentType
], {}, { exclude_me: true });
So I succeed in a handshake with the server using WebSocket:
var ws = new WebSocket('ws://1server address','example.json');
ws.onopen = function () {
console.log('websocket is connected ...')
ws.send('connected')
}
ws.onmessage = function (ev) {
console.log(ev);
}
But I could not see any data in the console.log(ev)
How can I get JSON data from the server??
I find a way to get data from the crossbar.
I was supposed to use autobahn library.
This is my solution:
var connection = new autobahn.Connection({ url : 'server url', realm: 'realm1'
});
connection.onopen = function (session) {
}
connection.open();
I hope this answer will be helpful to someone.