Reputation: 845
I have a page that lists all of the public chatrooms and I am trying to have: total occupants / max users
IE. (05/10 People in room)
The Extended Disco Info Result (Querying For Room Information) returns the current occupants in the room, but does not show what the maximum occupant spots are.
How would I go about retrieving the Max Users for the room(s)?
Upvotes: 0
Views: 1541
Reputation: 350
One can set the number of occupants in MUC's Configuration. Example 157 in XEP-0045
Using Stanza:
<field var='muc#roomconfig_maxusers'
label='Maximum Number of Occupants'>
<value>50</value>
</field>
Objective-C Code:
NSArray *fields = [newConfig elementsForName:@"field"];
for (NSXMLElement *field in fields)
{
NSString *var = [field attributeStringValueForName:@"var"];
if ([var isEqualToString:@"muc#roomconfig_maxusers"])
{
[field removeChildAtIndex:0];
[field addChild:[NSXMLElement elementWithName:@"value" stringValue:@"50"]];
}
[XMPPRoom configureRoomUsingOptions:newConfig]; }
Upvotes: 1
Reputation: 7924
In XEP-0045, just below example 10 is the text specifying allowed fields in the extended discovery result, which includes:
...any field defined for the muc#roomconfig FORM_TYPE can be included in the extended service discovery fields (as shown above for the "muc#roomconfig_changesubject" field).
So a server supporting this would return in the discovery result a field such as the following:
<field var='muc#roomconfig_maxusers'
label='Maximum Number of Occupants'>
<value>10</value>
</field>
If your server doesn't return this, perhaps file a feature request.
Upvotes: 1