Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 07-09-2007
xdm's Avatar
xdm xdm is offline
ZeroC Staff
 
Name: José Gutíerrez de la Concha Martínez
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Sep 2003
Location: La Coruña, Spain
Posts: 299
Glacier2 destroy session question

Hi i have a question regards Glacier2 sessions

When i call router->destroySession();

glacier automatic remove the session servant from the adapter, or must my code remove the Session servant?


I observer that ClientSessionI destructor is not automatic called in my case.

I using Ice-3.2 release version | gentoo linux gcc-4.6


Here is my SessionManager implementation.

Code:
Glacier2::SessionPrx Oz::SessionManagerI::create(const std::string& login,
    const Glacier2::SessionControlPrx& sessionControl,const Ice::Current& current){
    Glacier2::SessionPrx sessionPx = 0;
    try{
        Ice::Identity sessionId;
        sessionId.category= "_" + login;
        sessionId.name = IceUtil::generateUUID();
        QString userId = login.c_str();
        QStringList userIdTokens = userId.split("@");
        std::string userName = userIdTokens[0].toUtf8().data();
        std::string domainName = userIdTokens[1].toUtf8().data();
        Oz::Domains::IDomainPrx domainPx = _domainServer->getDomain(domainName);
        Oz::Domains::IUserPrx userPx = domainPx->getUser(userName);

        ClientSessionIPtr session = new ClientSessionI(sessionId,userPx,userName,domainPx,domainName);
        sessionPx = Glacier2::SessionPrx::uncheckedCast(current.adapter->add(session,sessionId));
    }catch(const std::exception& std_e){
        std::cerr<<"file: "<<__FILE__<<" line: "<<__LINE__<<" "<<std_e.what()<<std::endl;
    }
    return sessionPx;
}
Code for login
Code:
void Oz::Ui::Application::login(const QString& user,const QString& password){
    try{
        Glacier2::RouterPrx router = getRouter();
        _session = IClientSessionPrx::uncheckedCast(router->createSession(user.toUtf8().data(),password.toUtf8().data()));
        _adapter = communicator()->createObjectAdapter("Ui.Client");
        _adapter->activate();
        loginSuccess();
    }catch(const Glacier2::PermissionDeniedException& glacier2_e){
        showError(QString(glacier2_e.reason.c_str()));
    }catch(const Ice::Exception& ice_e){
        std::ostringstream os;
        os << ice_e;
        showError(QString(os.str().c_str()));
    }
}
Code for logout
Code:
void Oz::Ui::Application::logout(){
    try{
        _router->destroySession();
    }catch(const Ice::ConnectionLostException& connectionlost_e){
        //Expected when destroy session.
        _adapter->destroy();
        _session = 0;
        _mainWindow->logoutSuccess();
    }catch(const Ice::Exception& ice_e){
        showError(QString(ice_e.what()));
    }
}
Reply With Quote
  #2 (permalink)  
Old 07-09-2007
benoit's Avatar
benoit benoit is offline
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,564
You need to remove the session servant from the adapter. You can do this from the session destroy() method (which is called by Glacier2 when your client calls router->destroySession()).

See the demo from the demo/Glacier2/callback directory for an example.

Cheers,
Benoit.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to re-establish glacier2 session after connection explicitly closed? rhochmuth Help Center 10 03-22-2007 02:27 PM
Question about Glacier2 davidcr1983 Help Center 2 08-10-2006 05:13 PM
Session Management with Glacier2 question 123w456t Help Center 1 03-29-2006 06:46 PM
Glacier2 session expiration Nis Baggesen Help Center 10 03-21-2006 08:05 AM
Question about Glacier2! JaneShang Help Center 2 06-16-2005 03:47 AM


All times are GMT -4. The time now is 12:38 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.