Usage
Sample websockets usage in javascript:
const socket = io.connect('https://dataapi.vaclavlepic.com');
// Subscribe to temperature updates
socket.emit('subscribe', { measurement: 'outdoor_temperature' });
// Handle temperature updates
socket.on('outdoor_temperature_update', function(data) {
console.log(`Teplota: ${data.measurement_values[0]} °C at ${data.time_values[0]}`);
});
// Unsubscribe from temperature updates
function unsubscribe() {
socket.emit('unsubscribe', { measurement: 'outdoor_temperature' });
}
// Example: Call unsubscribe after 10 seconds
setTimeout(unsubscribe, 10000);
No Comments