OpenClient

StockSharp.cTrader.Native

继承自: Disposable

构造函数

OpenClient(string, uint)

Creates an instance of OpenClient which is not connected yet

host
The host name of API endpoint
port
The host port number

属性

Host : string

The API endpoint host that the current client is connected to

IsCompleted : bool

If client stream is completed without any error then it will return True, otherwise False

IsTerminated : bool

If there was any error (exception) on client stream then this will return True, otherwise False

Port : uint

The API host port that current client is connected to

方法

Connect(CancellationToken) : Task

Connects to the API based on you specified method

返回值: Task

ConnectTcp(CancellationToken) : Task

Connects to API by using a TCP client

返回值: Task

DisposeManaged()

Disposes the client, releases all used resources, and stops all running operations

GetLength(byte[]) : int

Returns the length of a received message without causing extra allocation

lengthBytes
The byte array of received length data

返回值: int

OnCompleted()

Completes each observer by calling their OnCompleted method

OnError(Exception)

Disposes the client and then calls each observer OnError after an exception thrown

exception
Exception
ReadTcp(CancellationToken) : Task

This method will read the TCP stream for incoming messages

cancellationToken
The cancellation token that will be used on ReadAsync calls

返回值: Task

SendMessage(ProtoMessage, CancellationToken) : Task

This method will insert your message on messages queue, it will not send the message instantly

message
Message
cancellationToken

返回值: Task

SendMessage``1(T, ProtoOAPayloadType, string, CancellationToken)

This method will insert your message on messages queue, it will not send the message instantly

message
Message
payloadType
Message Payload Type (ProtoOAPayloadType)
clientMsgId
The client message ID (optional)
cancellationToken

返回值: Task

SendMessage``1(T, string, CancellationToken)

This method will insert your message on messages queue, it will not send the message instantly By using this overload of SendMessage method you avoid passing the message payload type and it gets the payload from message itself

message
Message
clientMsgId
The client message ID (optional)
cancellationToken

返回值: Task

SendMessage``1(T, ProtoPayloadType, string, CancellationToken)

This method will insert your message on messages queue, it will not send the message instantly

message
Message
payloadType
Message Payload Type (ProtoPayloadType)
clientMsgId
The client message ID (optional)
cancellationToken

返回值: Task

ThrowObjectDisposedExceptionIfDisposed()

Throws ObjectDisposedException if the client was disposed

WriteTcp(byte[], CancellationToken) : Task

Writes the message bytes to TCP stream

messageByte
cancellationToken
The cancellation token that will be used on calling stream methods

返回值: Task

事件

MessageReceived : Action<ProtoMessage>

This event will be triggered when a message is received from the API