Lean  $LEAN_TAG$
IWebSocket.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  /// Wrapper for WebSocket4Net to enhance testability
22  /// </summary>
23  public interface IWebSocket
24  {
25  /// <summary>
26  /// Wraps constructor
27  /// </summary>
28  /// <param name="url">The target websocket url</param>
29  /// <param name="sessionToken">The websocket session token</param>
30  void Initialize(string url, string sessionToken = null);
31 
32  /// <summary>
33  /// Wraps send method
34  /// </summary>
35  /// <param name="data"></param>
36  void Send(string data);
37 
38  /// <summary>
39  /// Wraps Connect method
40  /// </summary>
41  void Connect();
42 
43  /// <summary>
44  /// Wraps Close method
45  /// </summary>
46  void Close();
47 
48  /// <summary>
49  /// Wraps IsOpen
50  /// </summary>
51  bool IsOpen { get; }
52 
53  /// <summary>
54  /// on message event
55  /// </summary>
56  event EventHandler<WebSocketMessage> Message;
57 
58  /// <summary>
59  /// On error event
60  /// </summary>
61  event EventHandler<WebSocketError> Error;
62 
63  /// <summary>
64  /// On Open event
65  /// </summary>
66  event EventHandler Open;
67 
68  /// <summary>
69  /// On Close event
70  /// </summary>
71  event EventHandler<WebSocketCloseData> Closed;
72  }
73 }