Table of Contents

Class BaseServer<TRequestId>

Namespace
StockSharp.Server.Core
Assembly
StockSharp.Server.Core.dll

Base implementation of IMessageListener.

public abstract class BaseServer<TRequestId> : BaseLogReceiver, IPersistable, IMessageListener, IMessageChannel, ICloneable<IMessageChannel>, ICloneable, ILogReceiver, ILogSource, IDisposable, ICloneable<BaseServer<TRequestId>>

Type Parameters

TRequestId

RequestId type.

Inheritance
BaseServer<TRequestId>
Implements
IPersistable
ICloneable<IMessageChannel>
ICloneable<BaseServer<TRequestId>>
Inherited Members
Extension Methods

Constructors

BaseServer(IAuthorization, ITransactionIdStorage, string, DateTime)

Initializes a new instance of the BaseServer<TRequestId>.

protected BaseServer(IAuthorization authorization, ITransactionIdStorage transactionIdStorage, string licenseFeatureId, DateTime componentTimestamp)

Parameters

authorization IAuthorization

The customer authentication.

transactionIdStorage ITransactionIdStorage

Transaction and request identifiers storage.

licenseFeatureId string

LicenseFeatureId

componentTimestamp DateTime

ComponentTimestamp

Properties

Authorization

The customer authentication.

[Browsable(false)]
public IAuthorization Authorization { get; }

Property Value

IAuthorization

ComponentTimestamp

Component timestamp.

public DateTime ComponentTimestamp { get; }

Property Value

DateTime

IsDemo

Demo mode only.

public bool IsDemo { get; protected set; }

Property Value

bool

LicenseFeatureId

License feature id to be sent as Logon response.

public string LicenseFeatureId { get; }

Property Value

string

Sessions

Active sessions.

public IEnumerable<IMessageListenerSession> Sessions { get; }

Property Value

IEnumerable<IMessageListenerSession>

Settings

Settings.

public abstract BaseServerSettings Settings { get; }

Property Value

BaseServerSettings

State

State.

[Browsable(false)]
public ChannelStates State { get; protected set; }

Property Value

ChannelStates

TransactionIdStorage

Transaction and request identifiers storage.

[Browsable(false)]
public ITransactionIdStorage TransactionIdStorage { get; }

Property Value

ITransactionIdStorage

Methods

AddSubscription(ServerSubscription)

Add subscription.

public abstract void AddSubscription(ServerSubscription subscription)

Parameters

subscription ServerSubscription

Subscription.

AddSubscription(SubscriptionInfo<IMessageListenerClientSession, TRequestId>)

public void AddSubscription(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Clone()

Create clone.

public abstract BaseServer<TRequestId> Clone()

Returns

BaseServer<TRequestId>

Clone.

Close()

Close channel.

public void Close()

Convert(string)

Try convert string to latin.

protected string Convert(string value)

Parameters

value string

Origin.

Returns

string

Result.

CreateTransactionId(IMessageListenerClientSession, string)

Generate a new request identifier.

protected long CreateTransactionId(IMessageListenerClientSession session, string requestId)

Parameters

session IMessageListenerClientSession

Session.

requestId string

Request identifier.

Returns

long

Transaction ID.

Disconnect(IMessageListenerSession)

Disconnect session.

public void Disconnect(IMessageListenerSession session)

Parameters

session IMessageListenerSession

Session.

DisposeManaged()

Release resources.

protected override void DisposeManaged()

GetServerSessions()

Get server sessions.

protected abstract IEnumerable<IMessageListenerSession> GetServerSessions()

Returns

IEnumerable<IMessageListenerSession>

Sessions.

GetSubscriptions(IMessageListenerSession)

Get subscription for the specified session.

public IEnumerable<ServerSubscription> GetSubscriptions(IMessageListenerSession session)

Parameters

session IMessageListenerSession

Session.

Returns

IEnumerable<ServerSubscription>

Subscriptions.

GetTransactionId(IMessageListenerClientSession, string)

Get the transaction ID.

protected static long GetTransactionId(IMessageListenerClientSession session, string requestId)

Parameters

session IMessageListenerClientSession

The session.

requestId string

The request identifier.

Returns

long

Transaction ID.

HasSubscriptions(DataType, SecurityId)

Are there subscribers.

public bool HasSubscriptions(DataType dataType, SecurityId securityId)

Parameters

dataType DataType

Market data type.

securityId SecurityId

Security ID.

Returns

bool

Are there subscribers.

Open()

Open channel.

public void Open()

RaiseNewOutMessage(IMessageListenerSession, Message)

To call the event NewOutMessage.

protected void RaiseNewOutMessage(IMessageListenerSession session, Message message)

Parameters

session IMessageListenerSession

Session.

message Message

Message.

RemoveSubscription(ServerSubscription)

Remove subscription.

public bool RemoveSubscription(ServerSubscription subscription)

Parameters

subscription ServerSubscription

Subscription.

Returns

bool

true if subscription was found, otherwise false.

Resume(IMessageListenerSession)

Resume session.

public void Resume(IMessageListenerSession session)

Parameters

session IMessageListenerSession

Session.

Resume(ServerSubscription)

Resume subscription.

public bool Resume(ServerSubscription subscription)

Parameters

subscription ServerSubscription

Subscription.

Returns

bool

true if subscription was found, otherwise false.

SendInMessage(Message)

Send message.

public bool SendInMessage(Message message)

Parameters

message Message

Message.

Returns

bool

true if the specified message was processed successfully, otherwise, false.

SendInMessage(SubscriptionInfo<IMessageListenerClientSession, TRequestId>[], Message)

Send message to subscriptions.

protected virtual bool SendInMessage(SubscriptionInfo<IMessageListenerClientSession, TRequestId>[] subscriptions, Message message)

Parameters

subscriptions SubscriptionInfo<IMessageListenerClientSession, TRequestId>[]

Subscriptions.

message Message

Message.

Returns

bool

Operation result.

StartProcessing(byte, TcpClient, Stream, CancellationToken)

Start processing of new connected client.

protected abstract Task StartProcessing(byte firstByte, TcpClient client, Stream clientStream, CancellationToken cancellationToken)

Parameters

firstByte byte

First received byte.

client TcpClient

TcpClient

clientStream Stream

GetStream()

cancellationToken CancellationToken

CancellationToken

Returns

Task

Task

Suspend(IMessageListenerSession)

Suspend session.

public void Suspend(IMessageListenerSession session)

Parameters

session IMessageListenerSession

Session.

Suspend(ServerSubscription)

Suspend subscription.

public bool Suspend(ServerSubscription subscription)

Parameters

subscription ServerSubscription

Subscription.

Returns

bool

true if subscription was found, otherwise false.

TryGetRequestId(IMessageListenerClientSession, long)

Get the request identifier.

protected static string TryGetRequestId(IMessageListenerClientSession session, long transactionId)

Parameters

session IMessageListenerClientSession

The session.

transactionId long

Transaction ID.

Returns

string

Request identifier.

WriteAvailableDataInfo(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, AvailableDataInfoMessage)

protected abstract ArraySegment<byte> WriteAvailableDataInfo(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, AvailableDataInfoMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message AvailableDataInfoMessage

AvailableDataInfoMessage

Returns

ArraySegment<byte>

Output buffer.

WriteBoard(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, BoardMessage)

protected abstract ArraySegment<byte> WriteBoard(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, BoardMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message BoardMessage

BoardMessage

Returns

ArraySegment<byte>

Output buffer.

WriteBoardState(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, BoardStateMessage)

protected abstract ArraySegment<byte> WriteBoardState(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, BoardStateMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message BoardStateMessage

BoardStateMessage

Returns

ArraySegment<byte>

Output buffer.

WriteCandle(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, CandleMessage)

protected abstract ArraySegment<byte> WriteCandle(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, CandleMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message CandleMessage

CandleMessage

Returns

ArraySegment<byte>

Output buffer.

WriteChangePassword(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, ChangePasswordMessage)

protected abstract ArraySegment<byte> WriteChangePassword(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, ChangePasswordMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message ChangePasswordMessage

ChangePasswordMessage

Returns

ArraySegment<byte>

Output buffer.

WriteError(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, ErrorMessage)

protected abstract ArraySegment<byte> WriteError(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, ErrorMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message ErrorMessage

ErrorMessage

Returns

ArraySegment<byte>

Output buffer.

WriteLevel1(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, Level1ChangeMessage)

protected abstract ArraySegment<byte> WriteLevel1(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, Level1ChangeMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message Level1ChangeMessage

Level1ChangeMessage

Returns

ArraySegment<byte>

Output buffer.

WriteNews(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, NewsMessage)

protected abstract ArraySegment<byte> WriteNews(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, NewsMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message NewsMessage

NewsMessage

Returns

ArraySegment<byte>

Output buffer.

WriteOrderBook(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, QuoteChangeMessage)

protected abstract ArraySegment<byte> WriteOrderBook(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, QuoteChangeMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message QuoteChangeMessage

QuoteChangeMessage

Returns

ArraySegment<byte>

Output buffer.

WriteOrderLog(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, ExecutionMessage)

Send OrderLog.

protected abstract ArraySegment<byte> WriteOrderLog(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, ExecutionMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message ExecutionMessage

OrderLog

Returns

ArraySegment<byte>

Output buffer.

WritePortfolio(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, PortfolioMessage)

protected abstract ArraySegment<byte> WritePortfolio(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, PortfolioMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message PortfolioMessage

PortfolioMessage

Returns

ArraySegment<byte>

Output buffer.

WritePosition(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, PositionChangeMessage)

protected abstract ArraySegment<byte> WritePosition(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, PositionChangeMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message PositionChangeMessage

PositionChangeMessage

Returns

ArraySegment<byte>

Output buffer.

WriteRemoteFile(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, RemoteFileMessage)

protected abstract ArraySegment<byte> WriteRemoteFile(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, RemoteFileMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message RemoteFileMessage

RemoteFileMessage

Returns

ArraySegment<byte>

Output buffer.

WriteSecurity(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, SecurityMessage)

protected abstract ArraySegment<byte> WriteSecurity(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, SecurityMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message SecurityMessage

SecurityMessage

Returns

ArraySegment<byte>

Output buffer.

WriteSecurityLegsInfo(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, SecurityLegsInfoMessage)

protected abstract ArraySegment<byte> WriteSecurityLegsInfo(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, SecurityLegsInfoMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message SecurityLegsInfoMessage

SecurityLegsInfoMessage

Returns

ArraySegment<byte>

Output buffer.

WriteSubscriptionFinished(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, SubscriptionFinishedMessage)

protected abstract ArraySegment<byte> WriteSubscriptionFinished(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, SubscriptionFinishedMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message SubscriptionFinishedMessage

SubscriptionFinishedMessage

Returns

ArraySegment<byte>

Output buffer.

WriteSubscriptionOnline(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, SubscriptionOnlineMessage)

protected abstract ArraySegment<byte> WriteSubscriptionOnline(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, SubscriptionOnlineMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message SubscriptionOnlineMessage

SubscriptionOnlineMessage

Returns

ArraySegment<byte>

Output buffer.

WriteSubscriptionResponse(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, SubscriptionResponseMessage)

protected abstract ArraySegment<byte> WriteSubscriptionResponse(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, SubscriptionResponseMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message SubscriptionResponseMessage

SubscriptionResponseMessage

Returns

ArraySegment<byte>

Output buffer.

WriteTick(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, ExecutionMessage)

Send Ticks.

protected abstract ArraySegment<byte> WriteTick(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, ExecutionMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message ExecutionMessage

Ticks

Returns

ArraySegment<byte>

Output buffer.

WriteTimeFrameInfo(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, TimeFrameInfoMessage)

protected abstract ArraySegment<byte> WriteTimeFrameInfo(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, TimeFrameInfoMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message TimeFrameInfoMessage

TimeFrameInfoMessage

Returns

ArraySegment<byte>

Output buffer.

WriteTransaction(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, ExecutionMessage)

protected abstract ArraySegment<byte> WriteTransaction(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, ExecutionMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message ExecutionMessage

Transactions

Returns

ArraySegment<byte>

Output buffer.

WriteUserInfo(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, UserInfoMessage)

protected abstract ArraySegment<byte> WriteUserInfo(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, UserInfoMessage message)

Parameters

subscription SubscriptionInfo<IMessageListenerClientSession, TRequestId>

Subscription.

message UserInfoMessage

UserInfoMessage

Returns

ArraySegment<byte>

Output buffer.

Events

NewOutMessage

New message event.

public event Action<IMessageListenerSession, Message> NewOutMessage

Event Type

Action<IMessageListenerSession, Message>

SessionConnected

Session connected event.

public event Action<IMessageListenerSession> SessionConnected

Event Type

Action<IMessageListenerSession>

SessionDisconnected

Session disconnected event.

public event Action<IMessageListenerSession> SessionDisconnected

Event Type

Action<IMessageListenerSession>

StateChanged

State change event.

public event Action StateChanged

Event Type

Action

SubscriptionChanged

Client subscription changed event.

public event Action<ServerSubscription> SubscriptionChanged

Event Type

Action<ServerSubscription>