mirror of
https://github.com/karl0ss/orvibo-b25-server-kex.git
synced 2025-05-02 05:23:41 +01:00
Fix typo in variable holding the Orvibo object
This commit is contained in:
parent
c0e9cd4cbf
commit
fe9fdf8e62
18
Example.js
18
Example.js
@ -17,37 +17,37 @@ const settings = {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
let orvbio = new Orvibo(settings);
|
let orvibo = new Orvibo(settings);
|
||||||
|
|
||||||
// When a socket first connects and initiates the handshake it will emit the connected event with the uid of the socket;
|
// When a socket first connects and initiates the handshake it will emit the connected event with the uid of the socket;
|
||||||
orvbio.on('plugConnected', ({uid, name}) => {
|
orvibo.on('plugConnected', ({uid, name}) => {
|
||||||
console.log(`Connected ${uid} name = ${name}`);
|
console.log(`Connected ${uid} name = ${name}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// If the socket state is updated this event will fire
|
// If the socket state is updated this event will fire
|
||||||
orvbio.on('plugStateUpdated', ({uid, state , name}) => {
|
orvibo.on('plugStateUpdated', ({uid, state , name}) => {
|
||||||
console.log(`Plug ${name} ${uid} updated state ${state}`);
|
console.log(`Plug ${name} ${uid} updated state ${state}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// The plug sends a hearbeat to let the server know it's still alive
|
// The plug sends a hearbeat to let the server know it's still alive
|
||||||
orvbio.on('gotHeartbeat', ({uid, name}) => {
|
orvibo.on('gotHeartbeat', ({uid, name}) => {
|
||||||
console.log(`Plug ${name} ${uid} sent heartbeat`);
|
console.log(`Plug ${name} ${uid} sent heartbeat`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Called when the plug disconnects
|
// Called when the plug disconnects
|
||||||
orvbio.on('plugDisconnected', ({uid, name }) => {
|
orvibo.on('plugDisconnected', ({uid, name }) => {
|
||||||
console.log(`Plug ${uid} - ${name} disconnected`);
|
console.log(`Plug ${uid} - ${name} disconnected`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Called when the plug disconnects with an error ie it's been unplugged
|
// Called when the plug disconnects with an error ie it's been unplugged
|
||||||
orvbio.on('plugDisconnectedWithError', ({uid, name }) => {
|
orvibo.on('plugDisconnectedWithError', ({uid, name }) => {
|
||||||
console.log(`Plug ${uid} - ${name} disconnected with error`);
|
console.log(`Plug ${uid} - ${name} disconnected with error`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Start the Orvibo socket server
|
// Start the Orvibo socket server
|
||||||
orvbio.startServer();
|
orvibo.startServer();
|
||||||
|
|
||||||
// Create a basic example HTTP server
|
// Create a basic example HTTP server
|
||||||
// If there are no parameters it will return the uid, state, modelId and name of the socket
|
// If there are no parameters it will return the uid, state, modelId and name of the socket
|
||||||
@ -58,11 +58,11 @@ const requestHandler = (request, response) => {
|
|||||||
response.writeHead(200, {'Content-Type': 'application/json'});
|
response.writeHead(200, {'Content-Type': 'application/json'});
|
||||||
let q = url.parse(request.url, true).query;
|
let q = url.parse(request.url, true).query;
|
||||||
if (q.uid != null) {
|
if (q.uid != null) {
|
||||||
orvbio.toggleSocket(q.uid);
|
orvibo.toggleSocket(q.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all currently connected sockets, their names and states
|
// Get all currently connected sockets, their names and states
|
||||||
let sockets = orvbio.getConnectedSocket();
|
let sockets = orvibo.getConnectedSocket();
|
||||||
|
|
||||||
response.end(JSON.stringify(sockets));
|
response.end(JSON.stringify(sockets));
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user