Unable to fetch realtime comments and view count for live video broadcast
ctle-vn opened this issue · comments
Using the code from the realtime example, here's my adapted code:
try {
console.log(`Startaing realtime with broadcast id: ${broadcast_id}`)
const ig: IgApiClientRealtime = withRealtime(new IgApiClient())
console.log('Startaing realtime2.')
ig.state.generateDevice(ig_username)
console.log('Startaing realtime3.')
await ig.account.login(ig_username, ig_password)
console.log('Startaing realtime4.')
const liveRealtimeCommentsSubscription = GraphQLSubscriptions.getLiveRealtimeCommentsSubscription(broadcast_id)
console.log(
`Startaing realtime5, ${JSON.stringify(
liveRealtimeCommentsSubscription,
)}, ${typeof liveRealtimeCommentsSubscription}`,
)
const sub = await ig.realtime.graphQlSubscribe(liveRealtimeCommentsSubscription)
console.log(`GraphQL subscription: ${JSON.stringify(sub)}`)
return sub
} catch (error) {
console.log(`fucked up ${error}`)
return {}
}
Startaing realtime with broadcast id:
Startaing realtime2.
Startaing realtime3.
Startaing realtime4.
Startaing realtime5, "1/graphqlsubscriptions//{"input_data":{"client_subscription_id":<id>,"broadcast_id":""}}", string
fucked up TypeError: Cannot read property 'updateSubscriptions' of undefined
Am I doing something wrong here?
--
Also was wondering if there was a way for me to get the real time view count for a live video broadcast?
You didn't connect the client. Only a connected client may sub to GQL.
Here you can see how to connect with GQL topics.
Hey @Nerixyz ,
Thanks for the quick response. I've connected the client now, although I'm not entirely familiar with MQTT. I don't see anything being logged when trying to catch new comments on a live video broadcast.
Is there a way for me to pass a callback function whenever the subscribed topic has a new event triggered? Specifically, trigger a callback function when a live broadcast receives a new comment.
You should listen to the liveRealtimeComments
event (.on('liveRealtimeComments', ...)
).
I also have the same problems