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
-
IPersistableICloneable<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
IAuthorizationThe customer authentication.
transactionIdStorage
ITransactionIdStorageTransaction and request identifiers storage.
licenseFeatureId
stringcomponentTimestamp
DateTime
Properties
Authorization
The customer authentication.
[Browsable(false)]
public IAuthorization Authorization { get; }
Property Value
- IAuthorization
ComponentTimestamp
Component timestamp.
public DateTime ComponentTimestamp { get; }
Property Value
IsDemo
Demo mode only.
public bool IsDemo { get; protected set; }
Property Value
LicenseFeatureId
License feature id to be sent as Logon response.
public string LicenseFeatureId { get; }
Property Value
Sessions
Active sessions.
public IEnumerable<IMessageListenerSession> Sessions { get; }
Property Value
Settings
Settings.
public abstract BaseServerSettings Settings { get; }
Property Value
State
State.
[Browsable(false)]
public ChannelStates State { get; protected set; }
Property Value
TransactionIdStorage
Transaction and request identifiers storage.
[Browsable(false)]
public ITransactionIdStorage TransactionIdStorage { get; }
Property Value
Methods
AddSubscription(ServerSubscription)
Add subscription.
public abstract void AddSubscription(ServerSubscription subscription)
Parameters
subscription
ServerSubscriptionSubscription.
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
stringOrigin.
Returns
- string
Result.
CreateTransactionId(IMessageListenerClientSession, string)
Generate a new request identifier.
protected long CreateTransactionId(IMessageListenerClientSession session, string requestId)
Parameters
session
IMessageListenerClientSessionSession.
requestId
stringRequest identifier.
Returns
- long
Transaction ID.
Disconnect(IMessageListenerSession)
Disconnect session.
public void Disconnect(IMessageListenerSession session)
Parameters
session
IMessageListenerSessionSession.
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
IMessageListenerSessionSession.
Returns
- IEnumerable<ServerSubscription>
Subscriptions.
GetTransactionId(IMessageListenerClientSession, string)
Get the transaction ID.
protected static long GetTransactionId(IMessageListenerClientSession session, string requestId)
Parameters
session
IMessageListenerClientSessionThe session.
requestId
stringThe request identifier.
Returns
- long
Transaction ID.
HasSubscriptions(DataType, SecurityId)
Are there subscribers.
public bool HasSubscriptions(DataType dataType, SecurityId securityId)
Parameters
dataType
DataTypeMarket data type.
securityId
SecurityIdSecurity 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
IMessageListenerSessionSession.
message
MessageMessage.
RemoveSubscription(ServerSubscription)
Remove subscription.
public bool RemoveSubscription(ServerSubscription subscription)
Parameters
subscription
ServerSubscriptionSubscription.
Returns
Resume(IMessageListenerSession)
Resume session.
public void Resume(IMessageListenerSession session)
Parameters
session
IMessageListenerSessionSession.
Resume(ServerSubscription)
Resume subscription.
public bool Resume(ServerSubscription subscription)
Parameters
subscription
ServerSubscriptionSubscription.
Returns
SendInMessage(Message)
Send message.
public bool SendInMessage(Message message)
Parameters
message
MessageMessage.
Returns
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
MessageMessage.
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
byteFirst received byte.
client
TcpClientclientStream
StreamcancellationToken
CancellationToken
Returns
Suspend(IMessageListenerSession)
Suspend session.
public void Suspend(IMessageListenerSession session)
Parameters
session
IMessageListenerSessionSession.
Suspend(ServerSubscription)
Suspend subscription.
public bool Suspend(ServerSubscription subscription)
Parameters
subscription
ServerSubscriptionSubscription.
Returns
TryGetRequestId(IMessageListenerClientSession, long)
Get the request identifier.
protected static string TryGetRequestId(IMessageListenerClientSession session, long transactionId)
Parameters
session
IMessageListenerClientSessionThe session.
transactionId
longTransaction ID.
Returns
- string
Request identifier.
WriteAvailableDataInfo(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, AvailableDataInfoMessage)
Send AvailableDataInfoMessage.
protected abstract ArraySegment<byte> WriteAvailableDataInfo(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, AvailableDataInfoMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
AvailableDataInfoMessage
Returns
- ArraySegment<byte>
Output buffer.
WriteBoard(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, BoardMessage)
Send BoardMessage.
protected abstract ArraySegment<byte> WriteBoard(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, BoardMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
BoardMessage
Returns
- ArraySegment<byte>
Output buffer.
WriteBoardState(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, BoardStateMessage)
Send BoardStateMessage.
protected abstract ArraySegment<byte> WriteBoardState(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, BoardStateMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
BoardStateMessage
Returns
- ArraySegment<byte>
Output buffer.
WriteCandle(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, CandleMessage)
Send CandleMessage.
protected abstract ArraySegment<byte> WriteCandle(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, CandleMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
CandleMessage
Returns
- ArraySegment<byte>
Output buffer.
WriteChangePassword(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, ChangePasswordMessage)
Send ChangePasswordMessage.
protected abstract ArraySegment<byte> WriteChangePassword(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, ChangePasswordMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
ChangePasswordMessage
Returns
- ArraySegment<byte>
Output buffer.
WriteError(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, ErrorMessage)
Send ErrorMessage.
protected abstract ArraySegment<byte> WriteError(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, ErrorMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
ErrorMessage
Returns
- ArraySegment<byte>
Output buffer.
WriteLevel1(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, Level1ChangeMessage)
Send Level1ChangeMessage.
protected abstract ArraySegment<byte> WriteLevel1(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, Level1ChangeMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
Level1ChangeMessage
Returns
- ArraySegment<byte>
Output buffer.
WriteNews(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, NewsMessage)
Send NewsMessage.
protected abstract ArraySegment<byte> WriteNews(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, NewsMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
NewsMessage
Returns
- ArraySegment<byte>
Output buffer.
WriteOrderBook(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, QuoteChangeMessage)
Send QuoteChangeMessage.
protected abstract ArraySegment<byte> WriteOrderBook(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, QuoteChangeMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
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
Returns
- ArraySegment<byte>
Output buffer.
WritePortfolio(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, PortfolioMessage)
Send PortfolioMessage.
protected abstract ArraySegment<byte> WritePortfolio(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, PortfolioMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
PortfolioMessage
Returns
- ArraySegment<byte>
Output buffer.
WritePosition(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, PositionChangeMessage)
Send PositionChangeMessage.
protected abstract ArraySegment<byte> WritePosition(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, PositionChangeMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
PositionChangeMessage
Returns
- ArraySegment<byte>
Output buffer.
WriteRemoteFile(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, RemoteFileMessage)
Send RemoteFileMessage.
protected abstract ArraySegment<byte> WriteRemoteFile(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, RemoteFileMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
RemoteFileMessage
Returns
- ArraySegment<byte>
Output buffer.
WriteSecurity(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, SecurityMessage)
Send SecurityMessage.
protected abstract ArraySegment<byte> WriteSecurity(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, SecurityMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
SecurityMessage
Returns
- ArraySegment<byte>
Output buffer.
WriteSecurityLegsInfo(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, SecurityLegsInfoMessage)
Send SecurityLegsInfoMessage.
protected abstract ArraySegment<byte> WriteSecurityLegsInfo(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, SecurityLegsInfoMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
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
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
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
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
Returns
- ArraySegment<byte>
Output buffer.
WriteTimeFrameInfo(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, TimeFrameInfoMessage)
Send TimeFrameInfoMessage.
protected abstract ArraySegment<byte> WriteTimeFrameInfo(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, TimeFrameInfoMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
TimeFrameInfoMessage
Returns
- ArraySegment<byte>
Output buffer.
WriteTransaction(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, ExecutionMessage)
Send Transactions.
protected abstract ArraySegment<byte> WriteTransaction(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, ExecutionMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
ExecutionMessage
Returns
- ArraySegment<byte>
Output buffer.
WriteUserInfo(SubscriptionInfo<IMessageListenerClientSession, TRequestId>, UserInfoMessage)
Send UserInfoMessage.
protected abstract ArraySegment<byte> WriteUserInfo(SubscriptionInfo<IMessageListenerClientSession, TRequestId> subscription, UserInfoMessage message)
Parameters
subscription
SubscriptionInfo<IMessageListenerClientSession, TRequestId>Subscription.
message
UserInfoMessage
Returns
- ArraySegment<byte>
Output buffer.
Events
NewOutMessage
New message event.
public event Action<IMessageListenerSession, Message> NewOutMessage
Event Type
SessionConnected
Session connected event.
public event Action<IMessageListenerSession> SessionConnected
Event Type
SessionDisconnected
Session disconnected event.
public event Action<IMessageListenerSession> SessionDisconnected
Event Type
StateChanged
State change event.
public event Action StateChanged
Event Type
SubscriptionChanged
Client subscription changed event.
public event Action<ServerSubscription> SubscriptionChanged