Skip to main content

Usage

Sample websockets usage in javascript:

const socket = io.connect('https://dataapi.vaclavlepic.com');

// Subscribe to temperature updates
socket.emit('subscribe', { measurement: 'temperature' });

// Handle temperature updates
socket.on('temperature_update', function(data) {
    console.log(`Teplota: ${data.measurement_values[0]} °C`);
});

// Unsubscribe from temperature updates
function unsubscribe() {
    socket.emit('unsubscribe', { measurement: 'temperature' });
}

// Example: Call unsubscribe after 10 seconds
setTimeout(unsubscribe, 10000);