Skip to content

kcapp/kcapp-sio-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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