Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
danz #1
Member since Jun 2009 · 5 posts
Group memberships: Members
Show profile · Link to this post
Subject: Creating and configuring a new conference room
Hi,
I am trying to create and configure a new conference room, so it'll be persistant and logged, with max 100 users.
I have tried to use both CreateReservedRoom and JoinRoom, but none worked.

This is my code:

            MucManager muc = new MucManager(xmppCnn);

            //muc.CreateReservedRoom(roomJid);

            muc.JoinRoom(roomJid, "a");

            muc.GrantOwnershipPrivileges(roomJid, xmppCnn.MyJID);

            Field f_form = new Field(FieldType.Hidden);
            f_form.Var = "http://jabber.org/protocol/muc#roomconfig";
            f_form.Value = "FORM_TYPE";

            Field f_persistent = new Field(FieldType.Boolean);
            f_persistent.Var = "muc#roomconfig_persistentroom";
            f_persistent.Value = "1";

            Field f_log_msgs = new Field(FieldType.Boolean);
            f_log_msgs.Var = "roomconfig_enablelogging";
            f_log_msgs.Value = "1";

            Field f_max_users = new Field(FieldType.List_Single);
            f_max_users.Var = "muc#roomconfig_maxusers";
            f_max_users.Value = "100";

            Data data = new Data(XDataFormType.form);
            data.AddField(f_form);
            data.AddChild(f_persistent);
            data.AddChild(f_log_msgs);
            data.AddChild(f_max_users);

            agsXMPP.protocol.x.muc.iq.owner.OwnerIq oIq = new agsXMPP.protocol.x.muc.iq.owner.OwnerIq(IqType.set, roomJid);
            oIq.Query.AddChild(data);
            xmppCnn.Send(oIq);

Also, I have managed to RequestConfigurationForm, but I couldn't edit the query's children nodes (only added another line with diff. value), and submitting it didn't work.

Will appreciate any help,
-Dan
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
You should create the room with JoinRoom first. Then wait until you get presence from the room.
After you got presence and no errors you can assume that the room is created.

Then use RequestConfigurationForm to request the configuration form. Fill out the form and send it back to the server.
You have to send all fields, not only a diff. In agsXmpp.Ui there is a xdata control which handles this for you. You can either use this control, or study the code and create you own control or forms.

Alex
Avatar
danz #3
Member since Jun 2009 · 5 posts
Group memberships: Members
Show profile · Link to this post
I can't seem to get it to work.
Here is the full info:

My code (sorry for the lame string replaces - a temporary solution)
            MucManager muc = new MucManager(xmppCnn);
            muc.JoinRoom(roomJid, "a");

            //...
            //...wait for presence...
            //...

            IQ configForm;

            muc.RequestConfigurationForm(...);

            //... getting response, placing the response IQ in variable configForm.

            //replacing the default room settings XML (temporary string replacing solution)
            configForm.Query.InnerXml = configForm.Query.InnerXml.Replace("var=\"muc#roomconfig_maxusers\" type=\"list-single\"><value>30","var=\"muc#roomconfig_maxusers\" type=\"list-single\"><value>100");
            configForm.Query.InnerXml = configForm.Query.InnerXml.Replace("var=\"muc#roomconfig_persistentroom\" type=\"boolean\"><value>0", "var=\"muc#roomconfig_persistentroom\" type=\"boolean\"><value>1");

            xmppCnn.IqGrabber.SendIq(configForm, GeneralIQHandler);

            muc.LeaveRoom(roomJid, "a");



The "fixed" XML sent at xmppCnn.Send:
- <iq xmlns="jabber:client" from="atest_m58_199@conference.danpc" to="dannntesttt@danpc/agsXMPP" type="result" id="agsXMPP_5">
- <query xmlns="http://jabber.org/protocol/muc#owner">
- <x xmlns="jabber:x:data" type="form">
  <title>Room configuration</title>
  <instructions>The room "atest_m58_199" has been created. To accept the default configuration, click the "OK" button. Or, modify the settings by completing the following form:</instructions>
- <field type="hidden" var="FORM_TYPE">
  <value>http://jabber.org/protocol/muc#roomconfig</value>
  </field>
- <field label="Room Name" var="muc#roomconfig_roomname" type="text-single">
  <value>atest_m58_199</value>
  </field>
- <field label="Description" var="muc#roomconfig_roomdesc" type="text-single">
  <value>atest_m58_199</value>
  </field>
- <field label="Allow Occupants to Change Subject" var="muc#roomconfig_changesubject" type="boolean">
  <value>0</value>
  </field>
- <field label="Maximum Room Occupants" var="muc#roomconfig_maxusers" type="list-single">
  <value>100</value>
- <option label="10">
  <value>10</value>
  </option>
- <option label="20">
  <value>20</value>
  </option>
- <option label="30">
  <value>30</value>
  </option>
- <option label="40">
  <value>40</value>
  </option>
- <option label="50">
  <value>50</value>
  </option>
- <option label="None">
  <value>0</value>
  </option>
  </field>
- <field label="Roles for Which Presence is Broadcast" var="muc#roomconfig_presencebroadcast" type="list-multi">
  <value>moderator</value>
  <value>participant</value>
  <value>visitor</value>
- <option label="Moderator">
  <value>moderator</value>
  </option>
- <option label="Participant">
  <value>participant</value>
  </option>
- <option label="Visitor">
  <value>visitor</value>
  </option>
  </field>
- <field label="List Room in Directory" var="muc#roomconfig_publicroom" type="boolean">
  <value>1</value>
  </field>
- <field label="Room is Persistent" var="muc#roomconfig_persistentroom" type="boolean">
  <value>1</value>
  </field>
- <field label="Room is Moderated" var="muc#roomconfig_moderatedroom" type="boolean">
  <value>0</value>
  </field>
- <field label="Room is Members-only" var="muc#roomconfig_membersonly" type="boolean">
  <value>0</value>
  </field>
- <field type="fixed">
  <value>Note: by default, only admins can send invitations in an members-only room.</value>
  </field>
- <field label="Allow Occupants to Invite Others" var="muc#roomconfig_allowinvites" type="boolean">
  <value>0</value>
  </field>
- <field label="Password Required to Enter Room" var="muc#roomconfig_passwordprotectedroom" type="boolean">
  <value>0</value>
  </field>
- <field type="fixed">
  <value>If a password is required to enter this room, you must specify the password below.</value>
  </field>
- <field label="Password" var="muc#roomconfig_roomsecret" type="text-private">
  <value />
  </field>
- <field label="Role that May Discover Real JIDs of Occupants" var="muc#roomconfig_whois" type="list-single">
  <value>anyone</value>
- <option label="Moderator">
  <value>moderators</value>
  </option>
- <option label="Anyone">
  <value>anyone</value>
  </option>
  </field>
- <field label="Log Room Conversations" var="muc#roomconfig_enablelogging" type="boolean">
  <value>0</value>
  </field>
- <field label="Only login with registered nickname" var="x-muc#roomconfig_reservednick" type="boolean">
  <value>0</value>
  </field>
- <field label="Allow Occupants to change nicknames" var="x-muc#roomconfig_canchangenick" type="boolean">
  <value>1</value>
  </field>
- <field label="Allow Users to register with the room" var="x-muc#roomconfig_registration" type="boolean">
  <value>1</value>
  </field>
- <field type="fixed">
  <value>You may specify administrators of this room. Please provide one JID per line.</value>
  </field>
  <field label="Room Admins" var="muc#roomconfig_roomadmins" type="jid-multi" />
- <field type="fixed">
  <value>You may specify additional owners for this room. Please provide one JID per line.</value>
  </field>
- <field label="Room Owners" var="muc#roomconfig_roomowners" type="jid-multi">
  <value>dannntesttt@danpc</value>
  </field>
  </x>
  </query>
  </iq>

Am I doing anything wrong?
should I change something else in the config-form before I submit it?

Thanks for your help,
-Dan

No response is received, which is strange.
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
your string replace cannot work because you have to create a new Iq which is totally different.
Please look at the component I suggested and XEP-0004 which shows you how to deal with xdata forms.

Alex
Avatar
danz #5
Member since Jun 2009 · 5 posts
Group memberships: Members
Show profile · Link to this post
Sorry, I have looked both at XEP-0004 specification, and on agsxmpp.ui, and I still cant get it to work.

XEP-0004 deeply describes XMPP protocol for this method, but not how to execute it with agsXMPP.
And about the agsXmpp.ui component, to edit a config form it display it in ui, and then builds the config form again from the UI form - I'm working on a server process, and there must be a faster way to edit the xml.

Once I have the config form IQ, what are the 2-3 commands I need to execute in order to change a setting and resubmit?

Anyway, I see that this question was already asked several times on this forum - never with a working code example.
Will it be possible to get a simple code example on configuring a new conference room?

-Dan
Avatar
Alex #6
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
When you request the configuration form then you get a result like this:
  1. <iq from='test2@conference.ag-software.de' to='...' id='agsXMPP_23' type='result'>
  2.     <query xmlns='http://jabber.org/protocol/muc#owner'>
  3.         <x xmlns='jabber:x:data' type='form'>
  4.             <!-- form content is here -->
  5.         </x>
  6.     </query>
  7. </iq>

Then you process the form, fill it out, and send it back in a new Iq with a new id of type set to the room. It doesn't matter if you process the from with a Ui or not. The result is always the same.

  1. <iq id="agsXMPP_24" to="test2@conference.ag-software.de" type="set">
  2.     <query xmlns="http://jabber.org/protocol/muc#owner">
  3.         <x type="submit" xmlns="jabber:x:data">
  4.             <field var="FORM_TYPE">
  5.                 <value>http://jabber.org/protocol/muc#roomconfig</value>
  6.             </field>
  7.             <field var="muc#roomconfig_roomname">
  8.                 <value></value>
  9.             </field>
  10.             <field var="muc#roomconfig_persistentroom">
  11.                 <value>0</value>
  12.             </field>
  13.             <field var="muc#roomconfig_publicroom">
  14.                 <value>1</value>
  15.             </field>
  16.             <field var="public_list">
  17.                 <value>1</value>
  18.             </field>
  19.             <field var="muc#roomconfig_passwordprotectedroom">
  20.                 <value>0</value>           
  21.             </field>
  22.             <field var="muc#roomconfig_roomsecret">
  23.                 <value></value>
  24.             </field>
  25.             <field var="muc#roomconfig_maxusers">
  26.                 <value>200</value>
  27.             </field>
  28.             <field var="muc#roomconfig_whois">
  29.                 <value>moderators</value>
  30.             </field>
  31.             <field var="muc#roomconfig_membersonly">
  32.                 <value>0</value>
  33.             </field>
  34.             <field var="muc#roomconfig_moderatedroom">
  35.                 <value>1</value>
  36.             </field>
  37.             <field var="members_by_default">
  38.                 <value>1</value>
  39.             </field>
  40.             <field var="muc#roomconfig_changesubject">
  41.                 <value>1</value>
  42.             </field>
  43.             <field var="allow_private_messages">
  44.                 <value>1</value>
  45.             </field>
  46.             <field var="allow_query_users">
  47.                 <value>1</value>
  48.             </field>
  49.             <field var="muc#roomconfig_allowinvites">
  50.                 <value>0</value>
  51.             </field>
  52.             <field var="muc#roomconfig_allowvisitorstatus">
  53.                 <value>1</value>
  54.             </field>
  55.             <field var="muc#roomconfig_allowvisitornickchange">
  56.                 <value>1</value>
  57.             </field>
  58.         </x>
  59.     </query>
  60. </iq>

On Success you to get a response of type result with the same id as your request.
  1. <iq from='test2@conference.ag-software.de' to='...' id='agsXMPP_24' type='result'>
  2.     <query xmlns='http://jabber.org/protocol/muc#owner'/>
  3. </iq>
Here is a small code example:
  1. private void SendRoomConfig()
  2. {
  3.     agsXMPP.protocol.x.muc.iq.owner.OwnerIq oIq = new agsXMPP.protocol.x.muc.iq.owner.OwnerIq();
  4.     oIq.Type = IqType.set;
  5.     oIq.To = new Jid("room1@conference.ag-software.de");
  6.  
  7.     agsXMPP.protocol.x.data.Data xForm = new Data();
  8.     xForm.Type = XDataFormType.submit;
  9.     /*
  10.         add more code here to fill out all fields in the form.
  11.     */
  12.     oIq.Query.AddChild(xForm);
  13.  
  14.     XmppCon.IqGrabber.SendIq(oIq, new IqCB(OnRoomConfigResult));
  15. }
  16.  
  17. private void OnRoomConfigResult(object sender, IQ iq, object data)
  18. {
  19.     if (iq.Type == IqType.result)
  20.     {
  21.         // success    
  22.     }
  23.     else if (iq.Type == IqType.error)
  24.     {
  25.         // error
  26.     }
  27. }
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS