Not logged in. · Lost password · Register
Forum: agsXMPP RSS
join room
Avatar
rhaibi #1
Member since Jun 2015 · 5 posts
Group memberships: Members
Show profile · Link to this post
Subject: muc invitation to join
how to invite a user to join a room and which event catch the invitation when it received by the other user?
thanks
Avatar
Alex #2
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
see here:
http://forum.ag-software.net/thread/1762-Force-join-JIDs-t…

the invite is coming in as a message in the OnMessage event.
Avatar
rhaibi #3
Member since Jun 2015 · 5 posts
Group memberships: Members
Show profile · Link to this post
Thanks for your replay
I successfully invited a user but when I try to join to user to the conference it seems that it's not working
this the code for the invitation :

  1. MucManager muc = new MucManager(GlobalVar.XmppCon);
  2. String roomname = GlobalVar.userconnected.UserName+GlobalVar.rdm.Next(3000).ToString()+ "@conference.srvopenfire.local";
  3. Jid m_RoomJid = new Jid(roomname);
  4. muc.JoinRoom(m_RoomJid, GlobalVar.userconnected.UserName);
  5. muc.CreateReservedRoom(m_RoomJid);
  6.            
  7. string toInvite;
  8. foreach (string user in usersSelected)
  9. {
  10.    toInvite = user + "@srvopenfire.local";
  11.    muc.Invite(new Jid(toInvite), m_RoomJid,"Reason");
  12. }

in the other hand i try to catch up the invitation in the OnMessage as u said with this code :

  1. MucManager muc = new MucManager(GlobalVar.XmppCon);
  2. Jid m_RoomJid = msg.From;
  3.  
  4. muc.JoinRoom(m_RoomJid, GlobalVar.userconnected.UserName);

this is the xml debug when i try to join the room

  1. RECV: <message from="admin1192@conference.srvopenfire.local" to="yrhaibi@srvopenfire.local"><x xmlns="http://jabber.org/protocol/muc#user"><invite from="admin@srvopenfire.local"><reason>Reason</reason></invite></x><x xmlns="jabber:x:conference" jid="admin1192@conference.srvopenfire.local"/></message>
  2.  
  3. SEND: <presence to="admin1192@conference.srvopenfire.local/yrhaibi"><x xmlns="http://jabber.org/protocol/muc" /></presence>
  4.  
  5. RECV: <presence to="yrhaibi@srvopenfire.local/TAO" from="admin1192@conference.srvopenfire.local/yrhaibi" type="error"><x xmlns="http://jabber.org/protocol/muc"/><error code="404" type="cancel"><item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></presence>
This post was edited 3 times, last on 2015-06-30, 22:26 by Alex.
Avatar
Alex #4
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
looks to me like oyu try to enter the room which its not ready yet, still locked.

See also here:
http://xmpp.org/extensions/xep-0045.html#enter-locked

Alex
Avatar
rhaibi #5
Member since Jun 2015 · 5 posts
Group memberships: Members
Show profile · Link to this post
Alex Thank u so much you are life saver :D
indeed the room wasn't configured when I tried to join a user to it, so this how I configured the room :


  1. private void OnRequestConfiguration(object sender, IQ iq, object obj)
  2. {
  3.     OwnerIq oIq = new OwnerIq();
  4.     oIq.Type = IqType.set;
  5.     oIq.To = new Jid(roomName);
  6.  
  7.     Data xForm = new Data(XDataFormType.form);
  8.     xForm.Type = XDataFormType.submit;
  9.  
  10.     Field f_form = new Field(FieldType.Hidden);
  11.     f_form.Var = "FORM_TYPE";
  12.     f_form.Value = "http://jabber.org/protocol/muc#roomconfig";
  13.     xForm.AddField(f_form);
  14.  
  15.     //Field f_title = new Field(FieldType.Text_Single);
  16.     //f_title.Var = "muc#roomconfig_roomname";
  17.     //f_title.Value = "VS2013-1";
  18.     //xForm.AddField(f_title);
  19.  
  20.     Field f_roomdesc = new Field(FieldType.Text_Single);
  21.     f_roomdesc.Var = "muc#roomconfig_roomdesc";
  22.     f_roomdesc.Value = GlobalVar.userconnected.UserName+" Created Room";
  23.     xForm.AddChild(f_roomdesc);
  24.  
  25.     Field f_changesubject = new Field(FieldType.Boolean);
  26.     f_changesubject.Var = "muc#roomconfig_changesubject";
  27.     f_changesubject.Value = "0";
  28.     xForm.AddChild(f_changesubject);
  29.  
  30.     Field f_public = new Field(FieldType.Boolean);
  31.     f_public.Var = "muc#roomconfig_publicroom";
  32.     f_public.Value = "0";
  33.     xForm.AddChild(f_public);
  34.  
  35.  
  36.  
  37.     Field f_moderatedroom = new Field(FieldType.Boolean);
  38.     f_moderatedroom.Var = "muc#roomconfig_moderatedroom";
  39.     f_moderatedroom.Value = "0";
  40.     xForm.AddChild(f_moderatedroom);
  41.  
  42.    
  43.  
  44.     Field f_allowinvites = new Field(FieldType.Boolean);
  45.     f_allowinvites.Var = "muc#roomconfig_allowinvites";
  46.     f_allowinvites.Value = "1";
  47.     xForm.AddChild(f_allowinvites);
  48.  
  49.  
  50.  
  51.  
  52.     oIq.Query.AddChild(xForm);
  53.     GlobalVar.XmppCon.IqGrabber.SendIq(oIq, new IqCB(OnRoomConfigResult), null);
  54.  
  55. }
  56. public void OnRoomConfigResult(object sender, IQ iq, object data)
  57. {
  58.     if (iq.Type == IqType.result)
  59.     {
  60.  
  61.  
  62.  
  63.         //success
  64.     }
  65.     else if (iq.Type == IqType.error)
  66.     {
  67.         //error
  68.     }
  69. }

after getting those methods done I called the RequestConfigurationForm method of the MucManager  :

  1. MucManager muc = new MucManager(GlobalVar.XmppCon);
  2. string roomID = GlobalVar.rdm.Next(3000).ToString();
  3. id = roomID;
  4.  roomname = GlobalVar.userconnected.UserName+roomID+ "@conference.srvopenfire.local";
  5. Jid m_RoomJid = new Jid(roomname);
  6.  
  7. muc.JoinRoom(m_RoomJid,GlobalVar.userconnected.UserName);
  8.  
  9. muc.RequestConfigurationForm(m_RoomJid, new IqCB(OnRequestConfiguration)

YOUSSEF
This post was edited on 2015-07-01, 19:23 by 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