Not logged in. · Lost password · Register
Forum: XMPP Protocol RSS
Avatar
preky #1
Member since Jan 2006 · 17 posts
Group memberships: Members
Show profile · Link to this post
Subject: Is user logged question?
in new version 0.71. can be stated this asumption...

   
  1.     public bool IsLogged()
  2.         {
  3.             if (XmppCon == null)
  4.                 return true;
  5.  
  6.             return ((XmppCon.Authenticated && XmppCon.XmppConnectionState == XmppConnectionState.Connected)
  7.                     || (XmppCon.RegisterAccount && XmppCon.XmppConnectionState == XmppConnectionState.Registered));
  8.         }

user is logged only if one of this two is true. Can somebody confirm me that?

thx
Preky
This post was edited on 2006-02-17, 22:00 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello preky,

i would use a global flag and set it to true if you get the OnLogin event, or OnRegister event, and set it to false if you get the OnClose event. This should work fine.

Alex
Avatar
preky #3
Member since Jan 2006 · 17 posts
Group memberships: Members
Show profile · Link to this post
Why couldn't I just check state of connection or user state? that seems to be cleaner.
Preky
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Alex,

You can if it works for you. But the XmppConnection state is used for internal stuff to avoid race conditions and could be used to show the current state of the connection. Lots of clients show it in the taskbar or somewhere else during the Login process. There is no guarantee that it will work in later versions too. We can also add more states when needed.

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: