SbeServer

StockSharp.Server.Sbe

SBE server.

Inherits: BaseProtocolServer<ClientSbeSession, SbeServerSubscription, SbeServerSettings>

Constructors

SbeServer
public SbeServer(IAuthorization authorization, ITransactionIdStorage transactionIdStorage, string licenseFeatureId, DateTime componentTimestamp, IMessageConverter converter)
sbeServer = SbeServer(authorization, transactionIdStorage, licenseFeatureId, componentTimestamp, converter)

Initializes a new instance of the SbeServer.

Properties

Authorization
public IAuthorization Authorization { get; }
value = sbeServer.Authorization

The customer authentication.

ComponentTimestamp
public DateTime ComponentTimestamp { get; }
value = sbeServer.ComponentTimestamp

Component timestamp.

Converter
public IMessageConverter Converter { get; }
value = sbeServer.Converter

Message converter.

LicenseFeatureId
public string LicenseFeatureId { get; }
value = sbeServer.LicenseFeatureId

License feature id.

SendOutHeartbeats
public bool SendOutHeartbeats { get; set; }
value = sbeServer.SendOutHeartbeats
sbeServer.SendOutHeartbeats = value

Send heartbeat via outgoing messages channel.

TransactionIdStorage
public ITransactionIdStorage TransactionIdStorage { get; }
value = sbeServer.TransactionIdStorage

Methods

ConfigureAcceptedSocket
private void ConfigureAcceptedSocket(TcpClient client)
sbeServer.ConfigureAcceptedSocket(client)

Apply TCP KeepAlive to an accepted client socket. Keep-alive probes keep NAT/firewall flow entries alive and surface dead peers quickly.

CreateSubscription
protected override SbeServerSubscription CreateSubscription(ClientSbeSession session, string requestId, ServerSubscription subscription, MessageTypes type)
result = sbeServer.CreateSubscription(session, requestId, subscription, type)
GetSessionKey
protected override string GetSessionKey(ClientSbeSession session)
result = sbeServer.GetSessionKey(session)
IsStubSubscription
protected override bool IsStubSubscription(SbeServerSubscription subscription)
result = sbeServer.IsStubSubscription(subscription)
NextResponseId
private static string NextResponseId()
result = SbeServer.NextResponseId()

Generate a unique response ID that does NOT pollute TransactionIdStorage. Prevents collision between server-generated response IDs and client-supplied mdReqIds.

OnClearListenerState
protected override void OnClearListenerState()
sbeServer.OnClearListenerState()

Clear protocol-specific listener state (stop listeners, etc.).

OnProcess
private IAsyncEnumerable<Message> OnProcess(ClientSbeSession session, ushort templateId, byte[] payload, CancellationToken cancellationToken)
result = sbeServer.OnProcess(session, templateId, payload, cancellationToken)

Dispatch incoming SBE message by templateId.

OnStartListeners
protected override void OnStartListeners(CancellationToken cancellationToken)
sbeServer.OnStartListeners(cancellationToken)

Start protocol-specific listeners (TCP, etc.). Add tasks to _backgroundTasks.

ProcessInMessage
protected override void ProcessInMessage(Message message, CancellationToken cancellationToken)
sbeServer.ProcessInMessage(message, cancellationToken)

Process an incoming message and route to subscribed clients.

ProcessLogout
protected override void ProcessLogout(ClientSbeSession session)
sbeServer.ProcessLogout(session)
ReadFramedMessageAsync
private static Task<byte[]> ReadFramedMessageAsync(Stream stream, CancellationToken cancellationToken)
result = SbeServer.ReadFramedMessageAsync(stream, cancellationToken)

SBE framing: read [4-byte length][payload].

ScheduleSessionWork
protected override void ScheduleSessionWork(ClientSbeSession session, ServerSubscription subscription, string requestId, Func<ClientSbeSession, string, CancellationToken, ValueTask<bool>> handler)
sbeServer.ScheduleSessionWork(session, subscription, requestId, handler)
WriteFramedAsync
private ValueTask<bool> WriteFramedAsync(ClientSbeSession session, Func<SbeRecordSerializer, byte[], int> serialize, CancellationToken cancellationToken)
result = sbeServer.WriteFramedAsync(session, serialize, cancellationToken)

Central outgoing write path: serialize the message into the session write buffer (growing and retrying on overflow so large frames are not dropped), then frame and send it. The buffer may be reallocated by Int32}), so it is re-read after serialization.