Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
ismailqadri #1
Member since Mar 2018 · 10 posts
Group memberships: Members
Show profile · Link to this post
Subject: Creating Chat room
Hi Admin,

Need help to create Chat room using agsXMPP. share me sample code how to create chat room and join chat room code samples.

Thanks in Advance.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
please study the MiniClient example. There should be everything you need.
Avatar
ismailqadri #3
Member since Mar 2018 · 10 posts
Group memberships: Members
Show profile · Link to this post
I didn't find anything related to create chatRoom.

and what is the difference between Add contact & Subscribe?
Avatar
ismailqadri #4
Member since Mar 2018 · 10 posts
Group memberships: Members
Show profile · Link to this post
Thanks Alex for your replay,

when I am creating chat room I am able to see in the server http://localhost:5280/admin/muc/rooms. but I am disconnecting these rooms are deleting or not showing on the server.

please help me on this.

Thanks in advance.
This post was edited on 2018-03-19, 15:48 by Alex.
Avatar
Alex #5
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
this is described in XEP-0045: Multi-User Chat.

Please look for persistent vs temporary rooms there. When the rooms is temporary and not configured as persistent it automatcially get destroyed when the last participant leaves
Avatar
ismailqadri #6
Member since Mar 2018 · 10 posts
Group memberships: Members
Show profile · Link to this post
I tried creating using below code and getting error as "Bad value of attribute 'to' in tag <iq/> qualified by namespace 'jabber:client'"
here is the XML for your reference.

  1. <query xmlns="http://jabber.org/protocol/muc#owner">
  2. <x xmlns="jabber:x:data" type="submit">
  3. <field type="hidden" var="FORM_TYPE">http://jabber.org/protocol/muc#roomconfig</field>
  4. <field type="boolean" var="muc#roomconfig_changesubject">1</field>
  5. <field type="boolean" var="muc#roomconfig_publicroom">1</field>
  6. <field type="boolean" var="muc#roomconfig_persistentroom">1</field>
  7. <field type="boolean" var="muc#roomconfig_moderatedroom">0</field>
  8. <field type="boolean" var="muc#roomconfig_membersonly">0</field>
  9. <field type="boolean" var="muc#roomconfig_allowinvites">0</field>
  10. <field type="boolean" var="muc#roomconfig_passwordprotectedroom">1</field>
  11. <field type="text-private" var="muc#roomconfig_roomsecret">mars</field>
  12. </x>
  13. </query>

and below is the code which I am using for creating the chat room.

  1. string name = "New Room";
  2. string descri = "Testing Room";
  3.    
  4. Jid jid = new Jid(name + "@conference.XXXXX.com");
  5. MucManager muc = new MucManager(this.XmppCon);
  6.  
  7. muc.JoinRoom(jid, this.XmppCon.Username);
  8.  
  9. muc.CreateReservedRoom(jid);  
  10.  
  11. muc.GrantOwnershipPrivileges(jid, this.XmppCon.MyJID);
  12.  
  13. muc.RequestConfigurationForm(jid, new IqCB(OnRequestConfiguration));
  14.  
  15. public void OnRequestConfiguration(object sender, IQ iq, object obj)
  16. {
  17.     agsXMPP.protocol.x.muc.iq.owner.OwnerIq oIq = new agsXMPP.protocol.x.muc.iq.owner.OwnerIq();
  18.     oIq.Type = IqType.set;
  19.     oIq.To = iq.From;
  20.  
  21.     agsXMPP.protocol.x.data.Data xForm = new agsXMPP.protocol.x.data.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.  
  84. public void OnRoomConigResult(object sender, IQ iq, object data)
  85. {
  86.     if (iq.Type == IqType.result)
  87.     {
  88.         //success
  89.     }
  90.     else if (iq.Type == IqType.error)
  91.     {
  92.         //error
  93.     }
  94. }
This post was edited 2 times, last on 2018-03-20, 09:42 by Alex.
Avatar
Alex #7
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you XML log contains only a partial stanza.
We need at least the complete request and complete server response
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