Nirvana C++ : Creating a Session

To interact with a Nirvana Server, the first thing to do is create a Nirvana Session (nSession) object, which is effectively your logical and physical connection to a Nirvana Realm.

Creating a Nirvana Session Object

  1. Create a nSessionAttributes object with the RNAME value of your choice

    std::string[] RNAME=({"nsp://127.0.0.1:9000"});
    int length = 1;
    nSessionAttributes *nsa=new nSessionAttributes(RNAME,length)
    
  2. Call the create method on nSessionFactory to create your session

    Session *mySession = nSessionFactory::create(nsa);
    

    Alternatively, if you require the use of a session reconnect handler to intercept the automatic reconnection attempts, pass an instance of that class too in the create method:

    class myReconnectHandler :
        public nReconnectHandler
         {
    
         //implement tasks associated with reconnection
    
         }
    
     myReconnectHandler rhandler=new myReconnectHandler();
     nSession *mySession=nSessionFactory::create(nsa, rhandler);
    
    

Initializing a Nirvana Session

  1. Initialise the session object to open the connection to the Nirvana Realm

    mySession->init();