Lean  $LEAN_TAG$
IConnectionHandler.cs
1 /*
2  * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3  * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14 */
15 
16 using System;
17 
19 {
20  /// <summary>
21  /// Provides handling of a brokerage or data feed connection
22  /// </summary>
23  public interface IConnectionHandler : IDisposable
24  {
25  /// <summary>
26  /// Event that fires when a connection loss is detected
27  /// </summary>
28  event EventHandler ConnectionLost;
29 
30  /// <summary>
31  /// Event that fires when a lost connection is restored
32  /// </summary>
33  event EventHandler ConnectionRestored;
34 
35  /// <summary>
36  /// Event that fires when a reconnection attempt is required
37  /// </summary>
38  event EventHandler ReconnectRequested;
39 
40  /// <summary>
41  /// Returns true if the connection has been lost
42  /// </summary>
43  bool IsConnectionLost { get; }
44 
45  /// <summary>
46  /// Initializes the connection handler
47  /// </summary>
48  /// <param name="connectionId">The connection id</param>
49  void Initialize(string connectionId);
50 
51  /// <summary>
52  /// Enables/disables monitoring of the connection
53  /// </summary>
54  /// <param name="isEnabled">True to enable monitoring, false otherwise</param>
55  void EnableMonitoring(bool isEnabled);
56 
57  /// <summary>
58  /// Notifies the connection handler that new data was received
59  /// </summary>
60  /// <param name="lastDataReceivedTime">The UTC timestamp of the last data point received</param>
61  void KeepAlive(DateTime lastDataReceivedTime);
62  }
63 }