Not logged in. · Lost password · Register
Forum: MatriX RSS
Page:  1  2  next
Avatar
skhanna #1
Member since Jul 2016 · 73 posts · Location: Indore
Group memberships: Members
Show profile
Subject: MUC management
Hi Alex,

I am new in XMPP development using matrix SDK.  I want to create room, room member, Join room, send room join request, send presence to room, remove member, send/receive message in room using C#. Can you help me to understand the flow and code of  these feature.

Thanks in advance
Sanjeev
Avatar
Alex #2
Member since Feb 2003 · 4298 posts · Location: Germany
Group memberships: Administrators, Members
Show profile
Hello,

when you are new then I would suggest to read and understand this document first XEP-0045: Multi-User Chat.

In MatriX most MUC functionality is build into the helper class called MucManager. IN the MiniClient you can also see the basic usage of it. To join a room just call MucManager.Enter(....). For modifying the members you will find there also functions.

See also this thread:
http://www.ag-software.net/2014/01/21/task-based-asynchron…

Don't hesitate to ask more questions when they come up.

Alex
Avatar
skhanna #3
Member since Jul 2016 · 73 posts · Location: Indore
Group memberships: Members
Show profile
Thanks Alex!!!
Avatar
skhanna #4
Member since Jul 2016 · 73 posts · Location: Indore
Group memberships: Members
Show profile
HI Alex,

I have few queries related to room.

(a) If I am a member of 5 rooms. So every login should I need to rejoin room?
(b) Suppose my XMPP connection is braked due to network then I need to reconnect. Should I need to do same process for XMPP login that I am doing for  first time application Login
(c) I need more celerity on first time room joining and every reconnect room joining.
(d) I checked login process by console application. After successful login connection immediately close. Can you check my code. Where I am doing mistake.
  1. Main(){
  2.   Matrix.License.LicenseManager.SetLicense(lic);
  3.   Initialize();
  4.   SocketLogin();
  5. }
  6.  
  7.  private static void Initialize() {
  8.       xmppClient = new XmppClient();
  9.       xmppClient.OnLogin += xmppClient_OnLogin;
  10.       ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertficate;
  11.       xmppClient.OnError += xmppClient_OnError;
  12.       xmppClient.OnClose += xmppClient_OnClose;
  13. }
  14.  
  15.  private static void SocketLogin() {
  16.       xmppClient.SetXmppDomain("....");
  17.       xmppClient.Hostname = ".......";
  18.       xmppClient.SetUsername("......");
  19.       xmppClient.Password = "..........";
  20.       xmppClient.Transport = Matrix.Net.Transport.Socket;
  21.       xmppClient.Status = "Online";
  22.       xmppClient.Show = Show.chat;      
  23.       xmppClient.Priority = 5;
  24.       xmppClient.SetResource("Server");
  25.       xmppClient.Port = 5222;
  26.  
  27.       try {
  28.         xmppClient.Open();
  29.       }
  30.       catch (Exception ex) {
  31.         Console.WriteLine(ex.Message);
  32.       }
  33.     }

Thanks in advance
Sanjeev Khanna
This post was edited on 2016-07-31, 13:24 by Alex.
Avatar
Alex #5
Member since Feb 2003 · 4298 posts · Location: Germany
Group memberships: Administrators, Members
Show profile
Quote by skhanna on 2016-07-30, 22:27:
1469910420

yes, when you disconnect you also get disconnect automatically from the groupchat room. Doesn't matter if you are a member or not.

Many existing applications use XEP-0048: Bookmarks to store bookmarks of favorite rooms, and also to store an autojoin flag so that software can easily retrieve all rooms which should be joined automatically on login (MucManagerEnter(...))

Quote by skhanna on 2016-07-30, 22:27:
1469910420

would need your Xml log to see whats going on. See here how to get the logs:
http://www.ag-software.net/matrix-xmpp-sdk/matrix-develope…

Have you looked at the existing sample codes from here?

Alex
Avatar
skhanna #6
Member since Jul 2016 · 73 posts · Location: Indore
Group memberships: Members
Show profile
Thanks Alex for your quick reply.
Sorry I am asking one more question. How to define bookmark in matrix and how to use it?

Sanjeev
Avatar
Alex #7
Member since Feb 2003 · 4298 posts · Location: Germany
Group memberships: Administrators, Members
Show profile
Here are some code snippets:

  1. // Save Bookmarks
  2. public async static void UpdateBookmarks(Account account)
  3. {
  4.     var privIq = new BookmarkStorageIq { Type = IqType.set };
  5.  
  6.     foreach (var conf in account.Bookmarks)
  7.         privIq.Private.Storage.AddConference(conf);
  8.  
  9.    
  10.     var res = await account.XmppClient.IqFilter.SendIqAsync(privIq);
  11.     if (res.Type == IqType.result)
  12.     {
  13.  
  14.     }
  15. }

  1. // Request Bookmarks from server
  2. private async Task GetBookmarks()
  3. {
  4.     var privIq = new BookmarkStorageIq { Type = IqType.get };
  5.     var bookRes = await XmppClient.IqFilter.SendIqAsync(privIq);
  6.    
  7.     if (bookRes.Type == IqType.result)
  8.     {
  9.         var priv = bookRes.Element<Private>();
  10.         if (priv != null)
  11.         {
  12.             var storage = priv.Storage;
  13.             if (storage != null)
  14.             {
  15.                 Bookmarks.Clear();
  16.                 foreach (var conf in storage.GetConferences())
  17.                 {
  18.                     Bookmarks.Add(conf);
  19.                 }
  20.             }
  21.         }
  22.     }
  23. }

Please also study and understand this extensions:
Avatar
skhanna #8
Member since Jul 2016 · 73 posts · Location: Indore
Group memberships: Members
Show profile
If I use bookmark should I require to call MUCManager.Invite() method?
Avatar
Alex #9
Member since Feb 2003 · 4298 posts · Location: Germany
Group memberships: Administrators, Members
Show profile
why would you need Invite?

On login Retrieve all Bookmarks, loop over them and enter every room which is set to AutoJoin with MucManager.Enter().
Bookmark does not mean that the room gets joined automatically on login.
Avatar
skhanna #10
Member since Jul 2016 · 73 posts · Location: Indore
Group memberships: Members
Show profile
Hi Alex

Quote by Alex:
why would you need Invite?

It's typing mistake. It's MucManager.Enter().

Quote by Alex:
On login Retrieve all Bookmarks, loop over them and enter every room which is set to AutoJoin with MucManager.Enter().
Bookmark does not mean that the room gets joined automatically on login.

Ok. Means bookmark is a storage where we can keep permanent data and use where we require. Right?
This post was edited on 2016-08-01, 17:09 by Alex.
Avatar
Alex #11
Member since Feb 2003 · 4298 posts · Location: Germany
Group memberships: Administrators, Members
Show profile
Quote by skhanna:
Ok. Means bookmark is a storage where we can keep permanent data and use where we require. Right?

correct, like favorites in your web browser
Avatar
skhanna #12
Member since Jul 2016 · 73 posts · Location: Indore
Group memberships: Members
Show profile
Alex,

Currently, in openfire server have 1000 rooms. I want to join all rooms that is available on openfire.  I am joining the room by looping all rooms. Is there any way to join all rooms without any loop.

Thanks in Advance
Sanjeev Khanna
Avatar
Alex #13
Member since Feb 2003 · 4298 posts · Location: Germany
Group memberships: Administrators, Members
Show profile
Quote by skhanna:
Currently, in openfire server have 1000 rooms. I want to join all rooms that is available on openfire.  I am joining the room by looping all rooms. Is there any way to join all rooms without any loop.
no there is not. This is teh way how XMPP is designed.
1000 rooms is a lot, not sure if you are using the right technology with rooms. Have you looked at XEP-0060: Publish-Subscribe

Alex
Avatar
skhanna #14
Member since Jul 2016 · 73 posts · Location: Indore
Group memberships: Members
Show profile
Hi Alex,

We have multitenant application. This application build on iOS and Android.  Each tenant have multiple users. User can chat between same tenant users. For each thread, we are creating room on openfire. On iOS and Android we have XMPP connection and it is use only for receive message. For send message it call Server Rest API. On server side we have implement XMPP using  matrix. Server  broadcast the message to room and save message in local DB. Server is responsible to broadcast the message to room and also update read and delivery date on server DB. So server should always joins all rooms. We have 200 tenant and each tenant have max 50-100 users. So we have more then 10000 rooms. At the time of connect and reconnect we need to joins all rooms because we need to send message and receive delivery date and read date on server.

Can you please suggest. It's right approach. Is there any performance issue if we send message using matrix on server. Is it compatible for joining 10000 rooms.

Thanks in Advance
Sanjeev
Avatar
Alex #15
Member since Feb 2003 · 4298 posts · Location: Germany
Group memberships: Administrators, Members
Show profile
As I said before, joining 1K rooms on login seems not the right approach to me.

Joining 10K rooms on login will take a while, because it requires you at least to exchange 20K packets over XMPP.
The delay is not a restriction of MatriX, MatriX is extremely fast. But exchanging this high number of packets creates also a high load on your server and takes a while to pass the network.

I would reconsider your design and evaluate if MUC id the the right solution for you, or if any of the other extensions or core features are better for this use case.
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:
Page:  1  2  next
Forum: MatriX RSS