That's all you need in this case. The event lets the plugin notify RightEdge when it has been disconnected or reconnected, but that only really applies to live data or broker plugins. A historical data service can just throw an exception if it gets disconnected while retrieving data.
I'm currently working on a SQL server data retrieval plugin (that I will eventually extend with ITickDataRetrieval) and would like to have this functionality (do something if the SqlConnection is lost).
The problem is I don't believe there is a way to know if an SQL server connection has been lost. I see the way it's handled in the TWSPlugin is the client.Error event raises ServiceEvent when appropriate. But what event will raise ServiceEvent in my case? The StateChanged event of an SqlConnection object is only fired when you explicitly call Close() or Dispose(), it won't raise if the "cable is unplugged". This after all makes sense since a server cannot tell you when it is down otherwise there would be no need for pinging.
How can I work around this? Id like for RightEdge to automatically attempt to reconnect to the server every few seconds following the connection loss, but without the ServiceEvent firing RightEdge won't know that it should be attempting to reconnect, is this correct or not?
Additionally, once the reconnect succeeds and IService.Connect() returns true I would also want it to "catch up" on the ticks it missed while disconnected from the server. Is this behavior already implemented in ITickDataRetrieval or will I have to handle this separately once the connection is restored?
Saturday December 31 2011 by