Nirvana C# Developers Guide - Create 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. The steps below describe session creation.

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

    string[] RNAME=({"nsp://127.0.0.1:9000"});
    nSessionAttributes nsa=new nSessionAttributes(RNAME);
    
  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 (nReconnectHandler) to intercept the automatic reconnection attempts, pass an instance of that class too in the create method:

    public class myReconnectHandler : nReconnectHandler{
      //implement tasks associated with reconnection
    }
    
    myReconnectHandler rhandler=new myReconnectHandler();
    nSession mySession=nSessionFactory.create(nsa, rhandler);
    
  3. Initialise the session object to open the connection to the Nirvana Realm

        mySession.init();
    

    To enable the use of DataGroups and to create an nDataStream , you should pass an instance of nDataStreamListener to the init call.

    public void SimpleStreamListener : nDataStreamListener{
      //implement onMessage callback for nDataStreamListener callbacks
    }
    
    nDataStreamListener myListener = new SimpleStreamListener();
    nDataStream myStream = mySession.init(myListener);
    

After initialising your Nirvana session, you will be connected to the Nirvana Realm. From that point, all functionality is subject to a Realm ACL check. If you call a method that requires a permission your credential does not have, you will receive an nSecurityException. Click here for more information on Nirvana ACLs.