Not logged in. · Lost password · Register
Forum: agsXMPP RSS
OnRosterItem and OnPresence event racing?
Avatar
c3csystems #1
User title: Anshuman
Member since Jun 2006 · 6 posts · Location: Kharagpur, India
Group memberships: Members
Show profile · Link to this post
Subject: A possible race condition?
Hi all,

Thanks for this useful library. I am new to C# and especially threading.

My problem is when I try to implement the library in my custom GUI and login to my local Wildfire server with one client already connected to the server using MiniClient or Miranda, the online presence of the MiniClient/Miranda user is not displayed. If, however, I just put a message box before calling the roster.SetPresence(pres) function from OnPresence event, everything works fine.

Any idea, why this is happening? And why putting a message box solves the problem (not exactly solves, but you know...).
I believe we should all pay our taxes with smile; I tried, but they only accept cash!
Avatar
c3csystems #2
User title: Anshuman
Member since Jun 2006 · 6 posts · Location: Kharagpur, India
Group memberships: Members
Show profile · Link to this post
Subject: Some additional info...
Hi,

I also noted few things...the above-mentioned problem only occurs for the first time when my application is executed. That is, when I disconnect while keeping the application (GUI) opened and login again, the contacts are displayed correctly.

Also, my login form is, in fact, not a form but a panel which I hide after OnLogin event has occured. However, in MiniClient example, the frmMain GUI seems to become unresponsive (albeit for a very small moment) once frmLogin has been disposed. May be this kind of halt in frmMain loading, solves the racing problem? In my case, the transition from panelLogin to panelLoggedIn is quite fast.

Could this be the possible reason? If so, suggest a way please to correct this out.
I believe we should all pay our taxes with smile; I tried, but they only accept cash!
Avatar
Jabberer #3
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
Hello,

are you invoking all the events from XmppClientConnection which update the GUI?
Did you try to debug the SetPresence method?
Software Developer
AG-Software
Avatar
Jabberer #4
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
and no, there can't be a race condition.

When you login the roster is requested first. Which fires the events OnRosterStart, multiple OnRosterItem and OnRosterEnd. You normally send you own presence after OnRosterEnd, and you don't get a presence packet from the server without sending your own presence. That means no presence before OnRosterEnd.
And its a good idea to Suspend the GUI in OnRosterStart and Resume it in OnRosterEnd.
Software Developer
AG-Software
Avatar
c3csystems #5
User title: Anshuman
Member since Jun 2006 · 6 posts · Location: Kharagpur, India
Group memberships: Members
Show profile · Link to this post
Subject: My mistake...
Thank you very much Jabberer,

It was my mistake that I was sending my presence in OnLogin event. Now I send my presence in OnRosterEnd and everything works like charm.

I did not know that server sends the presences when I send my presence. Where can I get such important informations? (I mean apart from the source...)
I believe we should all pay our taxes with smile; I tried, but they only accept cash!
Avatar
Alex #6
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

you can get this infos from the RFC's: http://www.xmpp.org/specs/
Or post your questions in the XMPP protocol forums and we try to answer them.
The XMPP mailing lists and forums are also very useful: http://www.jabber.org/about/lists.shtml

Alex
Avatar
c3csystems #7
User title: Anshuman
Member since Jun 2006 · 6 posts · Location: Kharagpur, India
Group memberships: Members
Show profile · Link to this post
Subject: Thank you very much...
Thanks Alex,

I will go through the links you provided.
I believe we should all pay our taxes with smile; I tried, but they only accept cash!
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