2

I have created a persistent MUC room using the ejabberd API "create_room_with_opts". I am now adding a user to the room by subscribing the user to the room using "subscribe_room" API with folowwing req and response.

Req:

{
  "user": "vishesh@dub/dummy",
  "nick": "vish",
  "room": "roomdub@conference.dub",
  "nodes": "urn:xmpp:mucsub:nodes:messages,urn:xmpp:mucsub:nodes:affiliations,urn:xmpp:mucsub:nodes:subject,urn:xmpp:mucsub:nodes:presence"
}

Res:

[
    "urn:xmpp:mucsub:nodes:messages",
    "urn:xmpp:mucsub:nodes:affiliations",
    "urn:xmpp:mucsub:nodes:subject",
    "urn:xmpp:mucsub:nodes:presence"
]

But when I list the number of occupants it lists as 0. I used "get_room_occupants_number" API which had following req and res.

Request:

{
    "name": "roomdub",
    "service": "conference.dub"
}

Response:

{
    "occupants": 0
}

I am unable to understand why I don't see the user I added? Did I miss any step?

1 Answers1

1

An account can be a room "subscriber", and receive notifications, and can also sends messages to the room. As described in https://docs.ejabberd.im/developer/xmpp-clients-bots/proposed-extensions/muc-sub/

Alternatively (or simultaneously), the account can be a room "occupant", and can see other room occupants' presence, how they join and leave, receives messages, private messages and can also send them. As described in https://xmpp.org/extensions/xep-0045.html

So, this sentence is wrong:

I am now adding a user to the room by subscribing the user to the room

You are not "adding" the user to the room, because after all that concept is not define in any of the protocols I mentioned. You are "subscribing" it to some room events. And doesn't make him an "occupant".

Badlop
  • 3,840
  • 1
  • 8
  • 9
  • Hi @Badlop, How can I make the user let say 'XYZ', Occupant of room1?? Please explain. – Mayuri More Feb 06 '20 at 10:41
  • 1
    A client becomes occupant of the room when he joins the room. There is no ejabberd command for an admin to do this. That can only be done by the client, following the XEP https://xmpp.org/extensions/xep-0045.html#enter – Badlop Feb 07 '20 at 12:20
  • Yeah, I did send presence, but when the user goes offline that user is removed from Room's occupants' list and is never added again. Can you please help me on the same. – Mayuri More Feb 10 '20 at 06:42
  • 1
    When a client disconnects, it leaves all the room where he was occupant. When the client connects again, he can join again those rooms. That's a matter of the client. For example, Tkabber has an "autojoin" feature. – Badlop Feb 11 '20 at 18:53
  • Yeah, did it. Anyways Thank you so much – Mayuri More Feb 12 '20 at 07:18