本文整理汇总了C#中StockSharp.InteractiveBrokers.Native.IBSocket.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# IBSocket.Connect方法的具体用法?C# IBSocket.Connect怎么用?C# IBSocket.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StockSharp.InteractiveBrokers.Native.IBSocket
的用法示例。
在下文中一共展示了IBSocket.Connect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSendInMessage
/// <summary>
/// Send message.
/// </summary>
/// <param name="message">Message.</param>
protected override void OnSendInMessage(Message message)
{
switch (message.Type)
{
case MessageTypes.Reset:
{
_depths.Clear();
_secIdByTradeIds.Clear();
if (_socket != null)
{
try
{
_socket.Dispose();
}
catch (Exception ex)
{
SendOutError(ex);
}
_socket = null;
}
SendOutMessage(new ResetMessage());
break;
}
case MessageTypes.Connect:
{
if (_socket != null)
throw new InvalidOperationException(LocalizedStrings.Str1619);
_socket = new IBSocket { Parent = this };
_socket.ProcessResponse += OnProcessResponse;
_socket.Connect(Address);
_socket.Send((int)_clientVersion);
_socket.ServerVersion = (ServerVersions)_socket.ReadInt();
if (_socket.ServerVersion >= ServerVersions.V20)
{
var str = _socket.ReadStr();
ConnectedTime = str.Substring(0, str.LastIndexOf(' ')).ToDateTime("yyyyMMdd HH:mm:ss");
}
if (_socket.ServerVersion < _minimumServerVersion)
{
throw new InvalidOperationException(LocalizedStrings.Str2513Params
.Put((int)_socket.ServerVersion, (int)_minimumServerVersion));
}
if (_socket.ServerVersion >= ServerVersions.V3)
{
if (_socket.ServerVersion >= ServerVersions.V70)
{
if (!ExtraAuth)
{
_socket.Send((int)RequestMessages.StartApi);
_socket.Send((int)ServerVersions.V2);
_socket.Send(ClientId);
if (_socket.ServerVersion >= ServerVersions.V72)
{
_socket.Send(OptionalCapabilities);
}
}
}
else
_socket.Send(ClientId);
}
_socket.StartListening(error => SendOutMessage(new ConnectMessage { Error = error }));
SendOutMessage(new ConnectMessage());
// отправляется автоматически
//RequestIds(1);
SetServerLogLevel();
SetMarketDataType();
RequestCurrentTime();
break;
}
case MessageTypes.Disconnect:
{
if (_socket == null)
throw new InvalidOperationException(LocalizedStrings.Str1856);
UnSubscribePosition();
UnSubscribeAccountSummary(_pfRequests.GetAndRemove("ALL"));
//.........这里部分代码省略.........