OnError

infotrade
Is it okay to call InitTicker again onError event?

code snippet:
private static void OnError(string Message)
{
File.AppendAllText(errorFile, "==========================================================" + Environment.NewLine);
File.AppendAllText(errorFile, DateTime.Now + Environment.NewLine);
File.AppendAllText(errorFile, "OnError: " + Message + Environment.NewLine);
Console.WriteLine("Error: " + Message);
ticker.Close();
initTicker();

File.AppendAllText(errorFile, "Call initTicker method for reconnecting socket" + Environment.NewLine);
}

private static void initTicker()
{
ticker = new Ticker(MyAPIKey, MyAccessToken);

ticker.OnTick += OnTick;
ticker.OnReconnect += OnReconnect;
ticker.OnNoReconnect += OnNoReconnect;
ticker.OnError += OnError;
ticker.OnClose += OnClose;
ticker.OnConnect += OnConnect;
ticker.OnOrderUpdate += OnOrderUpdate;

ticker.EnableReconnect(Interval: 5, Retries: 50);
ticker.Connect();
}
Sign In or Register to comment.