Skip to content

Latest commit

 

History

History
37 lines (30 loc) · 1.04 KB

README.md

File metadata and controls

37 lines (30 loc) · 1.04 KB

kcapp logo

kcapp-sio-client

socket io client for consuming events for live matches in kcapp

Usage

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

Connecting to a specific leg

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