SbeServer
SBE server.
Inherits: BaseProtocolServer<ClientSbeSession, SbeServerSubscription, SbeServerSettings>
Constructors
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
public IAuthorization Authorization { get; }
value = sbeServer.Authorization
The customer authentication.
public DateTime ComponentTimestamp { get; }
value = sbeServer.ComponentTimestamp
Component timestamp.
public IMessageConverter Converter { get; }
value = sbeServer.Converter
Message converter.
public string LicenseFeatureId { get; }
value = sbeServer.LicenseFeatureId
License feature id.
public bool SendOutHeartbeats { get; set; }
value = sbeServer.SendOutHeartbeats
sbeServer.SendOutHeartbeats = value
Send heartbeat via outgoing messages channel.
public ITransactionIdStorage TransactionIdStorage { get; }
value = sbeServer.TransactionIdStorage
Methods
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.
protected override SbeServerSubscription CreateSubscription(ClientSbeSession session, string requestId, ServerSubscription subscription, MessageTypes type)
result = sbeServer.CreateSubscription(session, requestId, subscription, type)
protected override string GetSessionKey(ClientSbeSession session)
result = sbeServer.GetSessionKey(session)
protected override bool IsStubSubscription(SbeServerSubscription subscription)
result = sbeServer.IsStubSubscription(subscription)
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.
protected override void OnClearListenerState()
sbeServer.OnClearListenerState()
Clear protocol-specific listener state (stop listeners, etc.).
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.
protected override void OnStartListeners(CancellationToken cancellationToken)
sbeServer.OnStartListeners(cancellationToken)
Start protocol-specific listeners (TCP, etc.). Add tasks to _backgroundTasks.
protected override void ProcessInMessage(Message message, CancellationToken cancellationToken)
sbeServer.ProcessInMessage(message, cancellationToken)
Process an incoming message and route to subscribed clients.
protected override void ProcessLogout(ClientSbeSession session)
sbeServer.ProcessLogout(session)
private static Task<byte[]> ReadFramedMessageAsync(Stream stream, CancellationToken cancellationToken)
result = SbeServer.ReadFramedMessageAsync(stream, cancellationToken)
SBE framing: read [4-byte length][payload].
protected override void ScheduleSessionWork(ClientSbeSession session, ServerSubscription subscription, string requestId, Func<ClientSbeSession, string, CancellationToken, ValueTask<bool>> handler)
sbeServer.ScheduleSessionWork(session, subscription, requestId, handler)
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.