const channel = supabase.channel(`presence-${roomId}`, {
config: {
presence: {
key: user.id,
},
},
});
channel
.on('presence', { event: 'sync' }, () => {
const newState = channel.presenceState()
console.log('sync', newState)
})
.subscribe(async (status) => {
if (status === 'SUBSCRIBED') {
const presenceTrackStatus = await channel.track({ 'user_id': 1 })
console.log(presenceTrackStatus, 'presenceTrackStatus')
}
})
return () => {
channel.unsubscribe();
}
const channel = supabase.channel(`presence-${roomId}`, {
config: {
presence: {
key: user.id,
},
},
});
channel
.on('presence', { event: 'sync' }, () => {
const newState = channel.presenceState()
console.log('sync', newState)
})
.subscribe(async (status) => {
if (status === 'SUBSCRIBED') {
const presenceTrackStatus = await channel.track({ 'user_id': 1 })
console.log(presenceTrackStatus, 'presenceTrackStatus')
}
})
return () => {
channel.unsubscribe();
}