Not logged in. · Lost password · Register
Forum: XMPP Protocol RSS
Avatar
robomotic #1
Member since Jun 2014 · 8 posts
Group memberships: Members
Show profile · Link to this post
Subject: PubSub notification on same account but different resources
Hello all,
first of all a big thank to everybody for producing such a nice project.
I have worked long time before on XMPP and mainly on Python, now I am working on a new project on C# so I am refreshing some of my knowledge of the XMPP protocol.
My current setup is the following:
Windows 8.1 machine with OpenFire, Visual Studio 2013 with Ag Matrix Min Client.
What I want to do is the following:
there is one user say paul at two different machines like paul@machine1, paul@machine2.
The user creates a Node on the PubSub and this is easy and publish/subscribe to the same node, in this way - I thought - I can simulate what OpenFire doesn't have yet (see long post here): broadcasting of messages to all the resources of a JID.
I am not interested here to keep all messages but rather I just want to get the last published item from the node.
Now the problem is that OpenFire only allows one connection at time for the same user (even if is coming from different IP addresses) and so when I connect from machine1, I get disconnected on machine2. So I have to constantly connect/disconnect to exchange the messages.
Is there another easy way to achieve this? I don't want the same user to register several nicknames each time, but rather have the same username and with that exchange information between different machines.

I hope my description is not so convoluted!
Avatar
Alex #2
Member since Feb 2003 · 4322 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
in XMPP you can connect unlimited times with the same user at the same time. Only the resource must be unique for each connection.
So make sure that you set xmppClient.Resource to a unique value for each of your connections.

Alex
Avatar
robomotic #3
Member since Jun 2014 · 8 posts
Group memberships: Members
Show profile · Link to this post
Hello Alex,
thank you will try that and let you know.
Cheers.
Avatar
robomotic #4
Member since Jun 2014 · 8 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #2
Oky I am looking into the Login.cs and the Matrix.xml settings.
Is this the right method to set the resource name:

  1.         public string Resource
  2.         {
  3.             get { return GetTag("Resource"); }
  4.             set { SetTag("Resource", value); }
  5.         }

And in the Matrix.xml settings there are lots of place where the tag is mentioned:
  1.     <member name="M:Matrix.Jid.#ctor(System.String,System.String,System.String)">
  2.       <summary>
  3.             Builds a new Jid object.
  4.             StringPrep is applied to the input string.
  5.             </summary>
  6.       <param name="user">XMPP User part</param>
  7.       <param name="server">XMPP Domain part</param>
  8.       <param name="resource">XMPP Resource part</param>
  9.     </member>
  10.  
  11.     <member name="M:Matrix.Jid.SetResource(System.String)">
  12.       <summary>
  13.             Sets the Resource part of the jid.
  14.             ResourcePrep is applied to the input string.
  15.             </summary>
  16.       <param name="resource">
  17.       </param>
  18.     </member>
  19.  
  20.     <member name="M:Matrix.Xmpp.Client.XmppClient.#ctor(System.String,System.String,System.String,System.String)">
  21.       <summary>
  22.             Initializes a new instance of the <see cref="T:Matrix.Xmpp.Client.XmppClient" /> class.
  23.             </summary>
  24.       <param name="user">
  25.       </param>
  26.       <param name="xmppDomain">
  27.       </param>
  28.       <param name="resource">
  29.       </param>
  30.       <param name="password">
  31.       </param>
  32.     </member>
  33.  
  34.     <member name="M:Matrix.Xmpp.Client.XmppClient.SetResource(System.String)">
  35.       <summary>
  36.             sets the Resource and prepares it according to the Resourceprep rules.
  37.             </summary>
  38.       <param name="resource">
  39.       </param>
  40.     </member>

Which tag will be affected by the SetTag in the XML?
This post was edited on 2014-06-17, 00:28 by Alex.
Avatar
Alex #5
Member since Feb 2003 · 4322 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by robomotic:
Oky I am looking into the Login.cs and the Matrix.xml settings.
Is this the right method to set the resource name:

  1.         public string Resource
  2.         {
  3.             get { return GetTag("Resource"); }
  4.             set { SetTag("Resource", value); }
  5.         }

Not sure if I understand your question correct.

Login.cs is a class which only saves the username, password, server and resource you used for your last login with the MiniClient example to the disk and loads these settings automatically on the next start.
If you want to login multiple clients with different resources all you hace to do is set xmppClient.Resource to a different string on all this resources. Eg. to client1, client2, client3 etc...

the MatriX.xml file which comes with the dll is the Xml documentation build from the source code comments. The purpose of this file is for intellisense only in the IDE and documentation in the Visual studio object browser for example.
Avatar
robomotic #6
Member since Jun 2014 · 8 posts
Group memberships: Members
Show profile · Link to this post
Hello Alex,
yes sorry for the confusion here's the logic :
I have added a form field into the MiniClient to change the resource automatically and I want to save the resource name into the xml settings.
I have modified the FrmMain to account for the resource in the method: InitSettings().
I actually got confused and find out that the XML file which is saved is settings.xml, I didn't realize that the Matrix.xml was for the intellisense!

Thanks a lot for the help, I know know where to look for!
Avatar
Alex #7
Member since Feb 2003 · 4322 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by robomotic:
Thanks a lot for the help, I know know where to look for!

Great. This code should demonstrate how easy MatriX could also be used to handle other Xml and store settings in a Xml configuration for example.

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: