Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
holysongc #1
Member since Sep 2014 · 3 posts
Group memberships: Members
Show profile · Link to this post
Subject: Can't change muc fields values
Try to create a muc room and config with custom settings, but it seems nothing is set on the server.

I am using Openfire as XMPP server.

Below is my code, and XML output, really need help...

thanks in advance!

  1. private void CreateRoom()
  2. {
  3.     string name = "vs2013";
  4.     //string desc = "testing room vs2013";
  5.     Jid roomjid = new Jid(name + "@conference.jay-pc");
  6.     Jid mejid = new Jid("jlee@jay-pc");
  7.  
  8.     MucManager muc = new MucManager(XmppCon);
  9.     muc.JoinRoom(roomjid,"a");
  10.     muc.GrantOwnershipPrivileges(roomjid, mejid);
  11.            
  12.     muc.RequestConfigurationForm(roomjid, new IqCB(OnRequestConfiguration));
  13. }
  14.  
  15. private void OnRequestConfiguration(object sender, IQ iq, object obj)
  16. {
  17.     OwnerIq oIq = new OwnerIq();
  18.     oIq.Type = IqType.set;
  19.     oIq.To = new Jid("vs2013-1@conference.jay-pc");
  20.  
  21.     Data xForm = new Data(XDataFormType.form);
  22.     xForm.Type = XDataFormType.submit;
  23.  
  24.     Field f_form = new Field(FieldType.Hidden);
  25.     f_form.Var = "FORM_TYPE";
  26.     f_form.Value = "http://jabber.org/protocol/muc#roomconfig";
  27.     xForm.AddField(f_form);
  28.  
  29.     Field f_title = new Field(FieldType.Text_Single);
  30.     f_title.Var = "muc#roomconfig_roomname";
  31.     f_title.Value = "VS2013-1";
  32.     xForm.AddField(f_title);
  33.  
  34.     Field f_roomdesc = new Field(FieldType.Text_Single);
  35.     f_roomdesc.Var = "muc#roomconfig_roomdesc";
  36.     f_roomdesc.Value = "VS2013 Created Room";
  37.     xForm.AddChild(f_roomdesc);
  38.  
  39.     Field f_changesubject = new Field(FieldType.Boolean);
  40.     f_changesubject.Var = "muc#roomconfig_changesubject";
  41.     f_changesubject.Value = "1";
  42.     xForm.AddChild(f_changesubject);
  43.  
  44.     Field f_public = new Field(FieldType.Boolean);
  45.     f_public.Var = "muc#roomconfig_publicroom";
  46.     f_public.Value = "1";
  47.     xForm.AddChild(f_public);
  48.  
  49.     Field f_persistent = new Field(FieldType.Boolean);
  50.     f_persistent.Var = "muc#roomconfig_persistentroom";
  51.     f_persistent.Value = "1";
  52.     xForm.AddChild(f_persistent);
  53.  
  54.     Field f_moderatedroom = new Field(FieldType.Boolean);
  55.     f_moderatedroom.Var = "muc#roomconfig_moderatedroom";
  56.     f_moderatedroom.Value = "0";
  57.     xForm.AddChild(f_moderatedroom);
  58.  
  59.     Field f_membersonly = new Field(FieldType.Boolean);
  60.     f_membersonly.Var = "muc#roomconfig_membersonly";
  61.     f_membersonly.Value = "0";
  62.     xForm.AddChild(f_membersonly);
  63.  
  64.     Field f_allowinvites = new Field(FieldType.Boolean);
  65.     f_allowinvites.Var = "muc#roomconfig_allowinvites";
  66.     f_allowinvites.Value = "0";
  67.     xForm.AddChild(f_allowinvites);
  68.  
  69.     Field f_private = new Field(FieldType.Boolean);
  70.     f_private.Var = "muc#roomconfig_passwordprotectedroom";
  71.     f_private.Value = "1";
  72.     xForm.AddChild(f_private);
  73.  
  74.     Field f_password = new Field(FieldType.Text_Private);
  75.     f_password.Var = "muc#roomconfig_roomsecret";
  76.     f_password.Value = "mars";
  77.     xForm.AddChild(f_password);
  78.  
  79.     oIq.Query.AddChild(xForm);
  80.     XmppCon.IqGrabber.SendIq(oIq, new IqCB(OnRoomConigResult), null);
  81.  
  82. }
  83. public void OnRoomConigResult(object sender, IQ iq, object data)
  84. {
  85.     if (iq.Type == IqType.result)
  86.     {
  87.         //success
  88.     }
  89.     else if (iq.Type == IqType.error)
  90.     {
  91.         //error
  92.     }
  93. }
This post was edited 2 times, last on 2014-10-03, 17:56 by Alex.
Avatar
holysongc #2
Member since Sep 2014 · 3 posts
Group memberships: Members
Show profile · Link to this post
XML Output:

  1. SEND: <presence><status /><priority>10</priority><c xmlns="http://jabber.org/protocol/caps" node="http://www.ag-software.de/miniclient/caps" ver="8RovUdtOmiAjzj+xI7SK5BCw3A8=" /></presence>
  2. SEND: <presence to="vs2013-1@conference.jay-pc/a"><x xmlns="http://jabber.org/protocol/muc" /></presence>
  3. SEND: <iq id="agsXMPP_11" to="vs2013-1@conference.jay-pc" type="set"><query xmlns="http://jabber.org/protocol/muc#admin"><item affiliation="owner" jid="jlee@jay-pc" /></query></iq>
  4. SEND: <iq id="agsXMPP_12" type="get" to="vs2013-1@conference.jay-pc"><query xmlns="http://jabber.org/protocol/muc#owner" /></iq>
  5. RECV: <presence xmlns="jabber:client" from="jlee@jay-pc/MiniClient" to="jlee@jay-pc/MiniClient"><status /><priority>10</priority><c xmlns="http://jabber.org/protocol/caps" ver="8RovUdtOmiAjzj+xI7SK5BCw3A8=" node="http://www.ag-software.de/miniclient/caps" /></presence>
  6. RECV: <presence xmlns="jabber:client" from="vs2013-1@conference.jay-pc/a" to="jlee@jay-pc/MiniClient"><x xmlns="http://jabber.org/protocol/muc#user"><item affiliation="owner" jid="jlee@jay-pc/MiniClient" role="moderator" /><status code="110" /><status code="100" /><status code="201" /></x></presence>
  7. RECV: <iq xmlns="jabber:client" type="result" from="vs2013-1@conference.jay-pc" to="jlee@jay-pc/MiniClient" id="agsXMPP_11" />
  8. RECV: <iq xmlns="jabber:client" type="result" from="vs2013-1@conference.jay-pc" to="jlee@jay-pc/MiniClient" id="agsXMPP_12"><query xmlns="http://jabber.org/protocol/muc#owner"><x xmlns="jabber:x:data" type="form"><title>Room configuration</title><instructions>The room "vs2013-1" 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 type="text-single" var="muc#roomconfig_roomname" label="Room Name"><value>vs2013-1</value></field><field type="text-single" var="muc#roomconfig_roomdesc" label="Description"><value>vs2013-1</value></field><field type="boolean" var="muc#roomconfig_changesubject" label="Allow Occupants to Change Subject"><value>0</value></field><field type="list-single" var="muc#roomconfig_maxusers" label="Maximum Room Occupants"><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><value>30</value></field><field type="list-multi" var="muc#roomconfig_presencebroadcast" label="Roles for Which Presence is Broadcast"><option label="Moderator"><value>moderator</value></option><option label="Participant"><value>participant</value></option><option label="Visitor"><value>visitor</value></option><value>moderator</value><value>participant</value><value>visitor</value></field><field type="boolean" var="muc#roomconfig_publicroom" label="List Room in Directory"><value>1</value></field><field type="boolean" var="muc#roomconfig_persistentroom" label="Room is Persistent"><value>0</value></field><field type="boolean" var="muc#roomconfig_moderatedroom" label="Room is Moderated"><value>0</value></field><field type="boolean" var="muc#roomconfig_membersonly" label="Room is Members-only"><value>0</value></field><field type="fixed"><value>Note: by default, only admins can send invitations in an members-only room.</value></field><field type="boolean" var="muc#roomconfig_allowinvites" label="Allow Occupants to Invite Others"><value>0</value></field><field type="boolean" var="muc#roomconfig_passwordprotectedroom" label="Password Required to Enter Room"><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 type="text-private" var="muc#roomconfig_roomsecret" label="Password" /><field type="list-single" var="muc#roomconfig_whois" label="Role that May Discover Real JIDs of Occupants"><option label="Moderator"><value>moderators</value></option><option label="Anyone"><value>anyone</value></option><value>anyone</value></field><field type="boolean" var="muc#roomconfig_enablelogging" label="Log Room Conversations"><value>0</value></field><field type="boolean" var="x-muc#roomconfig_reservednick" label="Only login with registered nickname"><value>0</value></field><field type="boolean" var="x-muc#roomconfig_canchangenick" label="Allow Occupants to change nicknames"><value>1</value></field><field type="fixed"><value>Allow Users to register with the room</value></field><field type="boolean" var="x-muc#roomconfig_registration" label="Allow Users to register with the room"><value>1</value></field><field type="fixed"><value>You may specify administrators of this room. Please provide one JID per line.</value></field><field type="jid-multi" var="muc#roomconfig_roomadmins" label="Room Admins" /><field type="fixed"><value>You may specify additional owners for this room. Please provide one JID per line.</value></field><field type="jid-multi" var="muc#roomconfig_roomowners" label="Room Owners"><value>jlee@jay-pc</value></field></x></query></iq>
  9. SEND: <iq id="agsXMPP_13" type="set" to="vs2013-1@conference.jay-pc"><query xmlns="http://jabber.org/protocol/muc#owner"><x xmlns="jabber:x:data" type="submit"><field type="hidden" var="FORM_TYPE">http://jabber.org/protocol/muc#roomconfig</field><field type="text-single" var="muc#roomconfig_roomname">VS2013-1</field><field type="text-single" var="muc#roomconfig_roomdesc">VS2013 Created Room</field><field type="boolean" var="muc#roomconfig_changesubject">1</field><field type="boolean" var="muc#roomconfig_publicroom">1</field><field type="boolean" var="muc#roomconfig_persistentroom">1</field><field type="boolean" var="muc#roomconfig_moderatedroom">0</field><field type="boolean" var="muc#roomconfig_membersonly">0</field><field type="boolean" var="muc#roomconfig_allowinvites">0</field><field type="boolean" var="muc#roomconfig_passwordprotectedroom">1</field><field type="text-private" var="muc#roomconfig_roomsecret">marlboro1</field></x></query></iq>
  10. RECV: <iq xmlns="jabber:client" type="result" from="vs2013-1@conference.jay-pc" to="jlee@jay-pc/MiniClient" id="agsXMPP_13" />
This post was edited on 2014-10-03, 17:56 by Alex.
Avatar
Alex #3
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Your Xml log looks fine, the server returns no error. So I guess your code is working, even it could be optimized.

Join room is asynchronous. After join room you must wait until the join room was successful, which gets indicated by the server in a presence packet.

When you create the room yourself calling GrantOwnershipPrivileges to yourself makes no sense. The creator of a room is always the owner by default.

For the room configuration you should retrieve the configuration form, and then loop over all fields and build the configuration form request in the loop and then send it.

Once you have done this and you still have problem please post the code and the xml again.
Avatar
holysongc #4
Member since Sep 2014 · 3 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex,

When you say all the fields, you mean ALL? I see some fields that start with "x-muc", that has to be set too?

thanks!
Avatar
Alex #5
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
yes all fields. Except of the fields which look like:

  1. <field type="fixed">
  2.    value>Allow Users to register with the room</value>
  3. </field>

those are comments only for the UI.

Alex
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