I want all the contact list in the roster to be displayed with presence of type online if they are connected and offline if they are not.

what i did ? I Requested the user's roster from the xmpp server and I Created IQ stanza to request the user's stanza then I Sent the IQ stanza to the server so I Received the Requested Roster then I Extracted all roster items from response's query element and store it in userRosterClone

const userRosterClone = this.userRoster.slice(); 

what i want to do now is to display online presence for each user in the roster so i created a function and send the roster list


 requestUserPresence(contactList): void{
  for (let i = 0 ; i<contactList.length; i++){

  console.log("Requesting the user\'s presence...");

  // 1. Creating presence stanza to request the user's contact list stanza

  const presence = $pres({
 id: generateUUIDv4(),
 to: contactList[i].contactJid,
 type: "subscribe"


  console.log("presence to request the user's presence:", 

  // 2. Sending the presence stanza to the server

   onReceivingRequestedPresence.bind(this), null, "presence");



the problem is onReceivingRequestedPresence is not working i can't send presence to the roster of type subscribed.


   console.log("Server Response to roster presence request: ", 

   const pres= $pres({
    from: presence.to,
    id: presence.id,
    to: this.connection.jid,
    type: "subscribed"

  // 2. Sending the IQ stanza to the server



0 Answers