socket io client for consuming events for live matches in kcapp
By default when connecting to kcapp
you will be subscribed to the /active
namespace which contains global events about matches startec etc.
// Create client
const kcapp = require('kcapp-sio-client/kcapp')("<server ip>", <server port> /*, <useragent>, <scheme> */);
// Connect to '/active' namespace
kcapp.connect(() => {
kcapp.on('new_match', (data) => {
// New match started
});
// Additional callbacks for other events ...
});
kcapp.connectLegNamespace(legId, (socket) => {
socket.on('score_update', (data) => {
// Handle score updates
});
socket.on('leg_finished', (data) => {
// Handle leg finished
});
socket.on('cancelled', (data) => {
// Handle leg cancelled
});
});