0

I initialize the chat client using chat token . i have two members in each channel . I want to know whether the user online or not. For that in backend i added twilio chat service instance { reachabilityEnabled: true } as the doc says and in frontend i wrote this code to get memebers information.

var member = await this.myChannel.getMembers();
member.forEach((member)=>{
  console.log(member)
  member.on('userInfoUpdated', (m)=>{  
      console.log(m);
  })
  member.on('updated', (m)=>{ console.log("hey")
    console.log(m);
  })      
})

but in member object i'm not getting any element from that i can check whether is user online or not. this is response of member object

channel: t {…}
services: e {…}
state: {attributes: {…}, dateCreated: Fri May 15 2020 19:---- (India Standard Time), dateUpdated: Fri May 1------------ (India Standard Time), sid: "MB7545cfa292314570a39385943ac541ad", typingTimeout: null, …}
_events: {updated: Array(2), userInfoUpdated: ƒ}
_eventsCount: 2
_maxListeners: undefined
attributes: (...)
dateCreated: (...)
dateUpdated: (...)
identity: (...)
isTyping: (...)
lastConsumedMessageIndex: (...)
lastConsumptionTimestamp: (...)
roleSid: (...)
sid: (...)
type: (...)

Please suggest me some way how will i do it because i'm stuck here very badly . if you need more code or information about this flow let me know but please suggest me some way. because there are question for this concern on any platform so from where i can clear it .

Vipul
  • 63
  • 1
  • 6

1 Answers1

0

Member and User are similar yet different objects. I believe your looking for the User resource to determine the IsOnline status.

After fetching your members; you can then use the members Identity to perform a user fetch which will give you that users IsOnline status.

See: Twilio User support docs.

David G
  • 161
  • 2
  • 6