Hi,
first, I suggest to use socket.io-client for your purpose, since you don’t need to make any server…
So, first step install it
npm install socket.io-client
Then, I prepared a code snippet with various examples for you:
[code]var io=require(‘socket.io-client’);
var socket= io.connect(‘http://192.168.31.242:3000’);
//Report successful connection
socket.on(‘connect’, function () {
console.log(‘Client Connected’);
});
//Report disconnection
socket.on(‘disconnect’, function () {
console.log(‘Client Disconnected’);
});
//Notify on player state changes, this includes volume changes, songs etc
socket.on(‘pushState’, function (data) {
console.log(data);
});
//Notify just the volume value
socket.on(‘pushState’, function (data) {
console.log(data.volume);
});
//Set Volume to 15
socket.emit(‘volume’, 15);
//Increase Volume by value specified by “On click Volume Change”, default is 10
//socket.emit(‘volume’, ‘+’);
//Decrease Volume by value specified by “On click Volume Change”, default is 10
//socket.emit(‘volume’, ‘-’);
[/code]
(sorry but the volume value in the docs was referring to old APIs, I will fix it as we speak)
Let me know how it works, I’m really interested!