Not logged in. · Lost password · Register
Forum: agsXMPP SDK Support RSS
Avatar
mayprog #1
Member since Mar 2006 · 61 posts
Group memberships: Members
Show profile · Link to this post
Subject: Jid constructor error
Dear Alex, i think at the Jid constructor the following change should be added:
from:
public Jid(string user, string server, string resource)
{
    m_user = user.ToLower();           
    m_server    = server.ToLower();
    m_resource    = resource;

    m_JID        = buildJid(m_user, m_server, m_resource);
}

to
public Jid(string user, string server, string resource)
{
    if ( user!= null )
        m_user = user.ToLower();           

    m_server    = server.ToLower();
    m_resource    = resource;

    m_JID        = buildJid(m_user, m_server, m_resource);
}

Especially when at the buildJid you do check the user variable if it is null.
There are cases that a user wants to create a jid only from a server and i prefer using the seperatelly user,server,resource consturctor rathen than the full string constructor.
Possibly a constructor such as:
public Jid(string server):this(null,server,null)

would be usefull too!

Thanks !
Avatar
Alex #2
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by mayprog:
public Jid(string server):this(null,server,null)

it's impossible to add this constructor, because a constructor with this parameters already exists. If you build a Jid with only the server part you can use:

  1. Jid jid = new Jid(""myserver.com");

or sis I understand something wrong?

Alex
Alexander Gnauck
AG-Software
Avatar
mayprog #3
Member since Mar 2006 · 61 posts
Group memberships: Members
Show profile · Link to this post
Yap, you are right i cannot create such constructor because  there is one already with one string parameter.
About the  if ( user!= null )
        m_user = user.ToLower();            ?

I don'u use the full string constructor for performance issues i might want to create many jids at the same time and i don't want string parsing to be performed every time. So i prefer using the user,server,resource constructor which won't do any string parsing. Thats why i added the if ( user!= null) ....

Don't you agree?
Thanks!
Avatar
Alex #4
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
i agree and added the check for null in my working copy.

Alex
Alexander Gnauck
AG-Software
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 SDK Support RSS