Forex.com / StoneX / CityIndex streams market data and account updates through Lightstreamer. The component speaks the native Lightstreamer TLCP 2.5 wire protocol over a WebSocket; no Lightstreamer native library is required.
When AutoReconnect is enabled (the default) the underlying WebSocket client WatchDog reopens the socket after network errors. The Lightstreamer protocol itself signals LOOP frames when the server wants the client to move to a different URL or rebind the session; the component handles those transparently and only raises OnForexDisconnect / OnForexConnect around full session breaks.
When the REST session expires (no Ping for a long time) the streaming server closes the session. The component calls LogOn again using the stored credentials, refreshes SessionToken, and restarts the Lightstreamer session with the new token.
Open the streaming session
oForex := TsgcWSAPI_Forex.Create(nil);
oForex.Credentials.UserName := '<username>';
oForex.Credentials.Password := '<password>';
oForex.Credentials.AppKey := '<appkey>';
oForex.OnForexConnect := ForexConnected;
oForex.OnForexDisconnect := ForexDisconnected;
oForex.OnForexException := ForexException;
oForex.AutoReconnect := True;
oForex.Connect;
// ... application ...
oForex.Disconnect;