/// React with LoginFailed, Exit Application public void onLoginFailed(string error) { Console.WriteLine("Login error " + error); logger.Debug("Login Error: {0}", error); this.error = error; connectionStatus = O2GSessionStatusCode.Unknown; }
private SessionStatusEnum convertO2GSessionStatusCodeToSessionStatusEnum(O2GSessionStatusCode sessionStatusCode) { switch (sessionStatusCode) { case O2GSessionStatusCode.Connected: return(SessionStatusEnum.Connected); case O2GSessionStatusCode.Disconnected: return(SessionStatusEnum.Disconnected); case O2GSessionStatusCode.Connecting: return(SessionStatusEnum.MSG1); case O2GSessionStatusCode.Disconnecting: return(SessionStatusEnum.MSG2); case O2GSessionStatusCode.Reconnecting: return(SessionStatusEnum.MSG3); case O2GSessionStatusCode.TradingSessionRequested: return(SessionStatusEnum.MSG4); case O2GSessionStatusCode.PriceSessionReconnecting: return(SessionStatusEnum.MSG5); case O2GSessionStatusCode.SessionLost: return(SessionStatusEnum.ERROR1); case O2GSessionStatusCode.Unknown: return(SessionStatusEnum.ERROR2); default: return(SessionStatusEnum.MSG10); } }
/// <summary> /// Called when FXCM session status changes /// </summary> /// <param name="status"></param> public void onSessionStatusChanged(O2GSessionStatusCode status) { switch (status) { case O2GSessionStatusCode.Connected: _connected = true; _syncSessionEvent.Set(); // Raise event to notify listeners if (_connectionEvent != null) { _connectionEvent(true); } break; case O2GSessionStatusCode.Disconnected: _connected = false; _syncSessionEvent.Set(); // Raise event to notify listeners if (_connectionEvent != null) { _connectionEvent(false); } break; } }
public void onSessionStatusChanged(O2GSessionStatusCode status) { Console.WriteLine("Status: " + status.ToString()); switch (status) { case O2GSessionStatusCode.TradingSessionRequested: if (string.IsNullOrEmpty(mSessionID)) { Console.WriteLine("Argument for trading session ID is missing"); } else { mSession.setTradingSession(mSessionID, mPin); } break; case O2GSessionStatusCode.Connected: mConnected = true; mDisconnected = false; mSyncSessionEvent.Set(); break; case O2GSessionStatusCode.Disconnected: mConnected = false; mDisconnected = true; mSyncSessionEvent.Set(); break; } }
public static SessionStatus GetSessionStatus(O2GSessionStatusCode value) { switch (value) { case O2GSessionStatusCode.Connected: return(SessionStatus.Connected); case O2GSessionStatusCode.Connecting: return(SessionStatus.Connecting); case O2GSessionStatusCode.Disconnected: return(SessionStatus.Disconnected); case O2GSessionStatusCode.Disconnecting: return(SessionStatus.Disconnecting); case O2GSessionStatusCode.PriceSessionReconnecting: return(SessionStatus.PriceSessionReconnecting); case O2GSessionStatusCode.Reconnecting: return(SessionStatus.Reconnecting); case O2GSessionStatusCode.SessionLost: return(SessionStatus.SessionLost); case O2GSessionStatusCode.TradingSessionRequested: return(SessionStatus.TradingSessionRequested); case O2GSessionStatusCode.Unknown: return(SessionStatus.Unknown); } throw new ArgumentOutOfRangeException("value"); }
/// <summary> /// Listener: When Trading session status is changed. /// </summary> /// <param name="status"></param> public void onSessionStatusChanged(O2GSessionStatusCode status) { Console.WriteLine("Status: " + status.ToString()); switch (status) { case O2GSessionStatusCode.TradingSessionRequested: if (string.IsNullOrEmpty(mSessionID)) { Console.WriteLine("Argument for trading session ID is missing"); } else { mSession.setTradingSession(mSessionID, mPin); } break; case O2GSessionStatusCode.Connected: mConnected = true; mDisconnected = false; mSyncSessionEvent.Set(); break; case O2GSessionStatusCode.Disconnected: mConnected = false; mDisconnected = true; mSyncSessionEvent.Set(); break; } }
private void Session_RequestFailed(object sender, RequestFailedEventArgs e) { lock (_csSessionStatus) { _sessionStatusCode = O2GSessionStatusCode.Disconnected; } _syncSessionEvent.Set(); }
private void Session_LoginFailed(object sender, LoginFailedEventArgs e) { lock (_csSessionStatus) { _sessionStatusCode = O2GSessionStatusCode.Disconnected; ErrorInfo = e.Error; } _syncSessionEvent.Set(); }
public void onSessionStatusChanged(O2GSessionStatusCode status) { SyncContext.Post(delegate(object state) { if (mComListener != null) { O2GSessionStatusCode evState = (O2GSessionStatusCode)state; mComListener.SessionStatusChanged((SessionStatusCode)(int)evState); } }, status); }
private void Stop() { if (_session != null) { _session.logout(); _syncSessionEvent.WaitOne(5000); _session.RequestCompleted -= Session_RequestCompleted; _session.RequestFailed -= Session_RequestFailed; _session.TablesUpdates -= Session_TablesUpdates; _session.LoginFailed -= Session_LoginFailed; _session.SessionStatusChanged -= Session_SessionStatusChanged; _sessionStatusCode = O2GSessionStatusCode.Disconnected; } }
public void onSessionStatusChanged(O2GSessionStatusCode code) { mCode = code; Console.WriteLine(code.ToString()); if (code == O2GSessionStatusCode.TradingSessionRequested) { if (SessionID == "") { Console.WriteLine("Argument for trading session ID is missing"); } else { mSession.setTradingSession(SessionID, mPin); } } }
public void onSessionStatusChanged(O2GSessionStatusCode status) { OnStatus?.Invoke(this, new StatusArgs((Status)(int)status)); switch (status) { case O2GSessionStatusCode.Connected: IsConnected = true; syncSessionEvent.Set(); break; case O2GSessionStatusCode.Disconnected: IsConnected = false; syncSessionEvent.Set(); break; } }
/// Function for Status changes - Status: Connected - Get Offers, Accounts; Request Closed Trades, Trades, Orders, Message public void onSessionStatusChanged(O2GSessionStatusCode code) { Console.WriteLine("status- " + code.ToString()); logger.Debug("Connection Status: {0}", code.ToString()); //HddMainForm.getInstance().setStatusLabel(code.ToString()); if (code == O2GSessionStatusCode.Connected) { subscibeForEvents(); Console.WriteLine("finished loading events"); connectionStatus = O2GSessionStatusCode.Connected; } else if (code == O2GSessionStatusCode.Disconnected) { unsubcribeEvents(); disconnect(); } }
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; } }
public void onSessionStatusChanged(O2GSessionStatusCode status) { Log.Debug($"FXCM session status changed: {status}"); if (status == O2GSessionStatusCode.Connected) { Task.Run(() => { _connectedAction(); }); } else if (status == O2GSessionStatusCode.Disconnected || status == O2GSessionStatusCode.Disconnecting || status == O2GSessionStatusCode.SessionLost) { Task.Run(() => { _connectionFailed(); }); } }
public void onSessionStatusChanged(O2GSessionStatusCode status) { OnStatus?.Invoke(this, new GenericArgs <O2GSessionStatusCode>(status)); switch (status) { case O2GSessionStatusCode.TradingSessionRequested: session.setTradingSession(sessionId, ""); break; case O2GSessionStatusCode.Connected: Connected = true; syncSessionEvent.Set(); break; case O2GSessionStatusCode.Disconnected: Connected = false; syncSessionEvent.Set(); break; } }
public void onSessionStatusChanged(O2GSessionStatusCode status) { Console.WriteLine("Status: " + status.ToString()); if (status == O2GSessionStatusCode.Connected) { mConnected = true; } else { mConnected = false; } if (status == O2GSessionStatusCode.Disconnected) { mDisconnected = true; } else { mDisconnected = false; } if (status == O2GSessionStatusCode.TradingSessionRequested) { if (BSFX.SessionID == "") { Console.WriteLine("Argument for trading session ID is missing"); } else { mSession.setTradingSession(BSFX.SessionID, BSFX.Pin); } } else if (status == O2GSessionStatusCode.Connected) { lock (mEvent) Monitor.PulseAll(mEvent); } }
public void onSessionStatusChanged(O2GSessionStatusCode ssc) { Console.WriteLine(ssc); switch (ssc) { case O2GSessionStatusCode.Connected: { _connection.ChangeStatus(FXSession.LOGIN_STATUS.LOGGED_IN); break; } case O2GSessionStatusCode.Connecting: case O2GSessionStatusCode.Disconnected: case O2GSessionStatusCode.Disconnecting: case O2GSessionStatusCode.PriceSessionReconnecting: case O2GSessionStatusCode.Reconnecting: case O2GSessionStatusCode.SessionLost: case O2GSessionStatusCode.TradingSessionRequested: case O2GSessionStatusCode.Unknown: break; } }
public void onSessionStatusChanged(O2GSessionStatusCode status) { SessionStatus = status; switch (status) { case O2GSessionStatusCode.Disconnected: this.Connected = false; waitHandle.Set(); break; //case O2GSessionStatusCode.Connecting: // break; //case O2GSessionStatusCode.TradingSessionRequested: // break; case O2GSessionStatusCode.Connected: this.Connected = true; waitHandle.Set(); break; //case O2GSessionStatusCode.Reconnecting: // break; //case O2GSessionStatusCode.Disconnecting: // break; case O2GSessionStatusCode.SessionLost: this.Connected = false; waitHandle.Set(); break; case O2GSessionStatusCode.PriceSessionReconnecting: //waitHandle.Set(); break; case O2GSessionStatusCode.Unknown: this.Connected = false; waitHandle.Set(); break; } }
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; } }
/// <summary> /// Listener: When Trading session status is changed /// </summary> /// <param name="status"></param> public void onSessionStatusChanged(O2GSessionStatusCode status) { switch (status) { case O2GSessionStatusCode.TradingSessionRequested: // If the trading session requires the session name or pin code... if (OnErrorEvent != null) { OnErrorEvent("Multi-session connectors aren't supported by this example\n"); } mTradingSession.logout(); break; case O2GSessionStatusCode.Connected: // login is completed // now we need collect data about the system properties O2GLoginRules loginRules = mTradingSession.getLoginRules(); mTZConverter = mTradingSession.getTimeConverter(); // get the trading day offset. O2GResponse response; response = loginRules.getSystemPropertiesResponse(); O2GSystemPropertiesReader reader = mTradingSession.getResponseReaderFactory().createSystemPropertiesReader(response); string eod = reader.Properties["END_TRADING_DAY"]; DateTime time = DateTime.ParseExact("01.01.1900_" + eod, "MM.dd.yyyy_HH:mm:ss", CultureInfo.InvariantCulture); // convert Trading day start to EST time because the trading day is always closed by New York time // so to avoid handling different hour depending on daylight saying time - use EST always // for candle calculations time = mTZConverter.convert(time, O2GTimeConverterTimeZone.UTC, O2GTimeConverterTimeZone.EST); // here we have the date when trading day begins, e.g. 17:00:00 // please note that if trading day begins before noon - it begins AFTER calendar date is started, // so the offset is positive (e.g. 03:00 is +3 offset). // if trading day begins after noon, it begins BEFORE calendar date is istarted, // so the offset is negative (e.g. 17:00 is -7 offset). if (time.Hour <= 12) { mTradingDayOffset = time.Hour; } else { mTradingDayOffset = time.Hour - 24; } // ...and now get the list of the offers to which the user is subscribed if (loginRules.isTableLoadedByDefault(O2GTableType.Offers)) { // if it is already loaded - just handle them response = loginRules.getTableRefreshResponse(O2GTableType.Offers); onRequestCompleted(null, response); } else { // otherwise create the request to get offers from the server O2GRequestFactory factory = mTradingSession.getRequestFactory(); O2GRequest offerRequest = factory.createRefreshTableRequest(O2GTableType.Offers); mTradingSession.sendRequest(offerRequest); } break; default: if (OnStateChange != null) { OnStateChange(false); } break; } }
// Implementation of IO2GSessionStatus interface public method onSessionStatusChanged public void onSessionStatusChanged(O2GSessionStatusCode status) { mStatus = status; switch (status) { case O2GSessionStatusCode.Connecting: break; case O2GSessionStatusCode.Connected: mConnected = (mStatus == O2GSessionStatusCode.Connected); manualEvent.Set(); CtrlTimer.getInstance().stopTimer("Session"); break; case O2GSessionStatusCode.Disconnecting: break; case O2GSessionStatusCode.Disconnected: mDisconnected = (mStatus == O2GSessionStatusCode.Disconnected); manualEvent.Set(); CtrlTimer.getInstance().stopTimer("Session"); break; case O2GSessionStatusCode.Reconnecting: break; case O2GSessionStatusCode.SessionLost: manualEvent.Set(); CtrlTimer.getInstance().stopTimer("Session"); break; } //log.info("Status: " + mStatus.ToString()); }
public static Status ToStatus(this O2GSessionStatusCode value) => (Status)(int)value;
void IO2GSessionStatus.onSessionStatusChanged(O2GSessionStatusCode status) { bool connected; string name; switch (status) { case O2GSessionStatusCode.Connected: connected = true; mTimeConverter = mSession.getTimeConverter(); O2GLoginRules rules = mSession.getLoginRules(); if (rules.isTableLoadedByDefault(O2GTableType.Offers)) { O2GResponse offers = rules.getTableRefreshResponse(O2GTableType.Offers); ReadOffers(offers); mReady = true; } else { O2GRequestFactory reqFactory = mSession.getRequestFactory(); O2GRequest request = reqFactory.createRefreshTableRequest(O2GTableType.Offers); mSession.sendRequest(request); mReady = false; } name = "connected"; break; case O2GSessionStatusCode.Connecting: connected = false; name = "connecting"; break; case O2GSessionStatusCode.Disconnected: connected = false; name = "disconnected"; break; case O2GSessionStatusCode.Disconnecting: connected = false; name = "disconnecting"; break; case O2GSessionStatusCode.PriceSessionReconnecting: connected = false; name = "price channel reconnecting"; break; case O2GSessionStatusCode.SessionLost: connected = false; name = "session has been lost"; break; default: connected = false; name = "unknown"; break; } if (!connected) { mReady = false; mTimeConverter = null; } if (OnSessionStatusChanged != null) { SessionStatusEventArgs args = new SessionStatusEventArgs(connected, name); OnSessionStatusChanged(this, args); } }