Skip to content

Live Status

The live status is a real time information and it needs another function that will be called everytime has an update in live status value. This function passed as a parameter recieve the current live status. The code below shows how to use this function in a JS code:

This feature is divided into two parts:

  • subscribeLiveStatus: You will subscribe for new changes in live status value.
  • unsubscribeLiveStatus: cancel the subscribe of first function.

In subscribe, you need to pass some parameters:

  • liveId: Id of the live to be watched
  • setLiveStatus: A function that recieve live status (as a int) and will be called everytime that the value of live status changes. The possible values for it are:
  • 0: Inactive live
  • 1: Active/Paused Live (Live don't started yet or it is paused)
  • 2: Running live
  • 3: Expired live
import { Metalives } from "metalives-sdk"
import dotenv from 'dotenv'

dotenv.config();

const client = new Metalives(process.env.SDK_TOKEN);

const setLiveStatus = (liveStatus) => {
    // Update your live status value
}

client.live.subscribeLiveStatus(liveId, setLiveStatus);