Closed ameyer closed 5 years ago
Hi Ameyer,
Really sorry, the documentation is massively out of date (and as you say incomplete), it's next on my list and something I'm looking to address in the next couple of weeks.
For now, the best thing I can recommend you do is take a look at the socketApi.js file - it lists all the possible commands in there. The commands are very much the same as the httpApi, they're just in camelcase. The commands may/may not accept a few params (depending on what they are), and the response is returned as a callback.
I use this sort of thing:
const connectThinglator = () => {
return new Promise(resolve => {
thinglatorSocket = socketIOClient(
`http://localhost:3003`
);
thinglatorSocket.on("connect", () => {
thinglatorSocket.off("connect");
resolve(thinglatorSocket);
});
thinglatorSocket.on("disconnect", () => {
console.log('disconnected');
});
thinglatorSocket.on("reconnect", () => {
console.log('reconnected');
});
});
};
await connectThinglator();
thinglatorSocket.emit(
"runCommand",
deviceId,
command,
value,
(info) => { console.log(info); }
);
It looks like there is a web-socket API. In fact I seem to be able to connect to it just fine. But what do I message to it? There seems to only be REST API documention