Fix typo in variable holding the Orvibo object

This commit is contained in:
Valcho Nedelchev 2018-01-31 16:21:28 +00:00
parent c0e9cd4cbf
commit fe9fdf8e62

View File

@ -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));
}; };