Logo Search packages:      
Sourcecode: gabber version File versions  Download package

void Session::connect ( const string &  server,
AuthType  atype,
const string &  username,
const string &  resource,
const string &  password,
bool  createuser = false 
)

Log into a server and authenticate.

See also:
AuthType
Parameters:
server The server to connect to.
atype The authentication type.
username The username to use.
resource The resource of this session.
password The password for this username.
createuser Whether to attempt to create a new user.

Definition at line 58 of file jabberoo-session.cc.

References csAuthReq, csConnected, csCreateUser, csNotConnected, and judo::ElementStream::reset().

{
     // If already connected, return
     if (_ConnState == csConnected)
        return;

     // Store properties for future use
     _AuthType = atype;
     _ServerID = server;
     _Username = username;
     _Resource = resource;
     _Password = password;

      // If we haven't connected at all, send the stream header
     if (_ConnState == csNotConnected)
     {
        this->reset(); // Reset ElementStream for new connection
        // Transmit opening sequence to establish the XML stream..    
        *this << "<stream:stream to='" << server.c_str()
            << "' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>";  
        // Set state properly..
        if (!newuser)
             _ConnState = csAuthReq;
        else
             _ConnState = csCreateUser;
     }
     // Otherwise, attempt to authenicate again     
     else
     {
        if (newuser)
             _ConnState = csCreateUser;
        authenticate();
     }
}


Generated by  Doxygen 1.6.0   Back to index