Exemplo n.º 1
0
        public void subscibeForEvents()
        {
            // grab a table manager
            tableManager = mSession.getTableManager();
            O2GTableManagerStatus managerStatus = tableManager.getStatus();

            while (managerStatus == O2GTableManagerStatus.TablesLoading)
            {
                Thread.Sleep(50);
                managerStatus = tableManager.getStatus();
            }
            logger.Info("tableManagerStatus: " + tableManager.getStatus().ToString());
            if (managerStatus == O2GTableManagerStatus.TablesLoadFailed) //Have to handle this better at some point.
            {
                return;
            }
            if (tableManager != null)
            {
                offersTbl = (O2GOffersTable)tableManager.getTable(O2GTableType.Offers);

                O2GSessionDescriptorCollection descs = mSession.getTradingSessionDescriptors();
                foreach (O2GSessionDescriptor desc in descs)
                {
                    Console.WriteLine("'{0}' '{1}' '{2}' {3}", desc.Id, desc.Name, desc.Description, desc.RequiresPin);
                    logger.Debug("{0}, {1}, {2}, {3}", desc.Id, desc.Name, desc.Description, desc.RequiresPin);
                    serverName = desc.Name;
                }
                O2GResponse resp = mSession.getLoginRules().getSystemPropertiesResponse();
            }
        }
        public void onSessionStatusChanged(O2GSessionStatusCode status)
        {
            Console.WriteLine("Status: " + status.ToString());
            switch (status)
            {
            case O2GSessionStatusCode.TradingSessionRequested:
                O2GSessionDescriptorCollection descs = mSession.getTradingSessionDescriptors();
                Console.WriteLine("Session descriptors:");
                Console.WriteLine("id, name, description, requires pin");
                foreach (O2GSessionDescriptor desc in descs)
                {
                    Console.WriteLine("'{0}' '{1}' '{2}' {3}", desc.Id, desc.Name, desc.Description, desc.RequiresPin);
                }
                Console.WriteLine();

                string sSessionID;
                if (string.IsNullOrEmpty(mLoginParams.SessionID))
                {
                    Console.WriteLine("Please enter trading session ID and press \'Enter\'");
                    sSessionID = Console.ReadLine();
                }
                else
                {
                    sSessionID = mLoginParams.SessionID;
                }

                mSession.setTradingSession(sSessionID.Trim(), mLoginParams.Pin);
                break;

            case O2GSessionStatusCode.Connected:
                mConnected    = true;
                mDisconnected = false;
                mSyncSessionEvent.Set();
                break;

            case O2GSessionStatusCode.Disconnected:
                mConnected    = false;
                mDisconnected = true;
                mSyncSessionEvent.Set();
                break;
            }
        }
Exemplo n.º 3
0
        private void Session_SessionStatusChanged(object sender, SessionStatusEventArgs e)
        {
            _sessionStatusCode = e.SessionStatus;
            switch (e.SessionStatus)
            {
            case O2GSessionStatusCode.Unknown:
                break;

            case O2GSessionStatusCode.PriceSessionReconnecting:
                break;

            case O2GSessionStatusCode.SessionLost:
                break;

            case O2GSessionStatusCode.Disconnecting:
                break;

            case O2GSessionStatusCode.Reconnecting:
                O2GTransport.setNumberOfReconnections(1);
                break;

            case O2GSessionStatusCode.Connected:
                _syncSessionEvent.Set();
                break;

            case O2GSessionStatusCode.TradingSessionRequested:
                O2GSessionDescriptorCollection descriptors = _session.getTradingSessionDescriptors();
                O2GSessionDescriptor           descriptor  = descriptors[0];
                _session.setTradingSession(descriptor.Id, "");
                break;

            case O2GSessionStatusCode.Connecting:
            case O2GSessionStatusCode.Disconnected:
                _syncSessionEvent.Set();
                break;
            }
        }