/*****************************************************************************
    *  Function    : createSession
    *  Description : This function creates a session object and opens the market
    *               bar service.  Returns false on failure of either.
    *  Arguments   : none
    *  Returns     : bool
    *****************************************************************************/
    private bool createSession()
    {
        if (d_session != null)
        {
            d_session.Stop();
        }

        System.Console.WriteLine("Connecting to " + d_sessionOptions.ServerHost +
                                 ":" + d_sessionOptions.ServerPort);
        d_session = new Session(d_sessionOptions, new EventHandler(processEvent));
        if (!d_session.Start())
        {
            System.Console.WriteLine("Failed to start session");
            return(false);
        }
        System.Console.WriteLine("Connected successfully\n");

        if (!d_session.OpenService("//blp/mktbar"))
        {
            System.Console.WriteLine("Failed to open service //blp/mktbar");
            d_session.Stop();
            return(false);
        }

        System.Console.WriteLine("Subscribing...");
        d_session.Subscribe(d_subscriptions);

        return(true);
    }
Exemple #2
0
 /// <summary>
 /// Dispose of the API connection.
 /// </summary>
 public void Dispose()
 {
     if (session != null)
     {
         try
         {
             session.Stop();
         }
         catch { }
         finally
         {
             session = null;
         }
     }
 }
Exemple #3
0
    /*****************************************************************************
    *  Function    : createSession
    *  Description : This function creates a session object and opens the market
    *               bar service.  Returns false on failure.
    *  Arguments   : none
    *  Returns     : bool
    *****************************************************************************/
    private bool createSession()
    {
        if (d_session != null)
        {
            d_session.Stop();
        }

        string authOptions = string.Empty;

        d_sessionOptions = new SessionOptions();

        if (d_authOption == "APPLICATION")
        {
            // Set Application Authentication Option
            authOptions  = "AuthenticationMode=APPLICATION_ONLY;";
            authOptions += "ApplicationAuthenticationType=APPNAME_AND_KEY;";
            // ApplicationName is the entry in EMRS.
            authOptions += "ApplicationName=" + d_name;
        }
        else if (d_authOption == "USER_APP")
        {
            // Set User and Application Authentication Option
            authOptions  = "AuthenticationMode=USER_AND_APPLICATION;";
            authOptions += "AuthenticationType=OS_LOGON;";
            authOptions += "ApplicationAuthenticationType=APPNAME_AND_KEY;";
            // ApplicationName is the entry in EMRS.
            authOptions += "ApplicationName=" + d_name;
        }
        else if (d_authOption == "USER_DS_APP")
        {
            // Set User and Application Authentication Option
            authOptions  = "AuthenticationMode=USER_AND_APPLICATION;";
            authOptions += "AuthenticationType=DIRECTORY_SERVICE;";
            authOptions += "DirSvcPropertyName=" + d_dsName + ";";
            authOptions += "ApplicationAuthenticationType=APPNAME_AND_KEY;";
            // ApplicationName is the entry in EMRS.
            authOptions += "ApplicationName=" + d_name;
        }
        else if (d_authOption == "DIRSVC")
        {
            // Authenticate user using active directory service property
            authOptions  = "AuthenticationType=DIRECTORY_SERVICE;";
            authOptions += "DirSvcPropertyName=" + d_dsName;
        }
        else
        {
            // Authenticate user using windows/unix login name (default)
            authOptions = "AuthenticationType=OS_LOGON";
        }

        System.Console.WriteLine("Authentication Options = " + authOptions);
        d_sessionOptions.AuthenticationOptions = authOptions;

        SessionOptions.ServerAddress[] servers = new SessionOptions.ServerAddress[d_hosts.Count];
        int index = 0;

        System.Console.WriteLine("Connecting to port " + d_port.ToString() + " on host(s):");
        foreach (string host in d_hosts)
        {
            servers[index] = new SessionOptions.ServerAddress(host, d_port);
            System.Console.WriteLine(host);
            index++;
        }

        // auto restart on disconnect
        d_sessionOptions.ServerAddresses            = servers;
        d_sessionOptions.AutoRestartOnDisconnection = true;
        d_sessionOptions.NumStartAttempts           = d_hosts.Count;
        // change default subscription service
        d_sessionOptions.DefaultSubscriptionService = MKTBAR_SVC;

        // create session and start
        d_session = new Session(d_sessionOptions, processEvent);
        return(d_session.Start());
    }
 public void CloseSession()
 {
     // Close the session
     session.Stop();
 }