Interface IFixSession
This interface is the main interface user works with. It represents IFIXSession either acceptor or initiator. And capable to send/receive messages.
Namespace: FixAntenna.FixEngine
Assembly: FixAntenna.Core.dll
Syntax
public interface IFixSession
Methods
AddInSessionLevelMessageListener(IFixMessageListener)
Add listeners to receive session level incoming messages. FIX session level message type:
- 'A' - Logon
- '0' - Heartbeat
- '1' - Test Request
- '2' - Resend Request
- '3' - Reject
- '4' - Sequence Reset
- '5' - Logout
Declaration
void AddInSessionLevelMessageListener(IFixMessageListener listener)
Parameters
| Type | Name | Description |
|---|---|---|
| IFixMessageListener | listener | the user specified listener |
AddOutSessionLevelMessageListener(ITypedFixMessageListener)
Declaration
void AddOutSessionLevelMessageListener(ITypedFixMessageListener listener)
Parameters
| Type | Name | Description |
|---|---|---|
| ITypedFixMessageListener | listener |
AddUserGlobalMessageHandler(AbstractUserGlobalMessageHandler)
Declaration
void AddUserGlobalMessageHandler(AbstractUserGlobalMessageHandler userMessageHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| AbstractUserGlobalMessageHandler | userMessageHandler |
Connect()
Connects to remote counterparty, if initiator or accepts incoming connection if acceptor.
Declaration
void Connect()
Exceptions
| Type | Condition |
|---|---|
| System.IO.IOException | I/O exception if error occurred |
Disconnect(String)
Gracefully disconnects current session.
Logoff with specified reason will be sent to your counterparty.
Note: This method doesn't guarantee immediate shutdown, since FIX protocol require us to wait for counterparty logoff reply.
Declaration
void Disconnect(string reason)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | reason | the reason |
Dispose()
Disposes current session, removes its reference from GlobalSessionManager and frees all allocated resources. Normally should be called after disconnect().
However it is possible to call this method for active session without previous disconnect() that will abnormally terminate fix session by closing fix connection (without logon exchange). This is useful to terminate stuck sessions if standard FIX logoff procedure doesn't work.
Declaration
void Dispose()
GetInSeqNum()
Declaration
long GetInSeqNum()
Returns
| Type | Description |
|---|---|
| System.Int64 |
GetMessageValidator()
Returns message validator.
Declaration
IMessageValidator GetMessageValidator()
Returns
| Type | Description |
|---|---|
| IMessageValidator | message validator for current session |
GetOutSeqNum()
Declaration
long GetOutSeqNum()
Returns
| Type | Description |
|---|---|
| System.Int64 |
GetSessionParameters()
Returns the cloned session connection parameters instance.
Declaration
SessionParameters GetSessionParameters()
Returns
| Type | Description |
|---|---|
| SessionParameters | SessionParameters - session parameters |
GetSessionState()
Returns session state.
Declaration
SessionState GetSessionState()
Returns
| Type | Description |
|---|---|
| SessionState | SessionState - session state |
Init()
Initialize FIX session. This allows to put messages to session. These messages will be send after connect.
Declaration
void Init()
Exceptions
| Type | Condition |
|---|---|
| System.IO.IOException | I/O exception if error occurred |
PrepareMessage(FixMessage, MessageStructure)
Builds FixMessage object from FixMessage object.
Declaration
FixMessage PrepareMessage(FixMessage message, MessageStructure structure)
Parameters
| Type | Name | Description |
|---|---|---|
| FixMessage | message | FixMessage object |
| MessageStructure | structure | message structure |
Returns
| Type | Description |
|---|---|
| FixMessage | FixMessage object |
Exceptions
| Type | Condition |
|---|---|
| PreparedMessageException |
PrepareMessage(FixMessage, String, MessageStructure)
Builds FixMessage object from FixMessage object.
Declaration
FixMessage PrepareMessage(FixMessage message, string type, MessageStructure structure)
Parameters
| Type | Name | Description |
|---|---|---|
| FixMessage | message | FixMessage object |
| System.String | type | type of the message |
| MessageStructure | structure | message structure |
Returns
| Type | Description |
|---|---|
| FixMessage | FixMessage object |
Exceptions
| Type | Condition |
|---|---|
| PreparedMessageException |
PrepareMessage(String, MessageStructure)
Builds FixMessage object with specified type, message structure and prefilled header information
Declaration
FixMessage PrepareMessage(string msgType, MessageStructure userStructure)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | msgType | message type |
| MessageStructure | userStructure | message structure |
Returns
| Type | Description |
|---|---|
| FixMessage | FixMessage object |
PrepareMessageFromString(Byte[], MessageStructure)
Builds FixMessage object from String object.
Declaration
FixMessage PrepareMessageFromString(byte[] message, MessageStructure structure)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | message | message string |
| MessageStructure | structure | message structure object |
Returns
| Type | Description |
|---|---|
| FixMessage | FixMessage object |
Exceptions
| Type | Condition |
|---|---|
| PreparedMessageException |
PrepareMessageFromString(Byte[], String, MessageStructure)
Builds FixMessage object from String object.
Declaration
FixMessage PrepareMessageFromString(byte[] message, string type, MessageStructure structure)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | message | message string |
| System.String | type | message type |
| MessageStructure | structure | message structure object |
Returns
| Type | Description |
|---|---|
| FixMessage | FixMessage object |
Exceptions
| Type | Condition |
|---|---|
| PreparedMessageException |
Reject(String)
Reject incoming connection for acceptor.
Not applicable for initiator.
Declaration
void Reject(string reason)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | reason |
Exceptions
| Type | Condition |
|---|---|
| System.IO.IOException | I/O exception if error occurred |
ResetSequenceNumbers()
Allows user to reset sequences numbers by sending logon with 141=Y.
Notice: Only supported for FIX versions 4.1 and above. Notice: The logon message will be send only when session is in connected state.
Declaration
void ResetSequenceNumbers()
ResetSequenceNumbers(Boolean)
Allows user to reset sequences numbers by sending logon with 141=Y.
Notice: Only supported for FIX versions 4.1 and above.
Notice: The logon message will be send only when session is in connected state.
Declaration
void ResetSequenceNumbers(bool checkGapFillBefore)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | checkGapFillBefore |
If true the TR will be sent before introday logon otherwise only intraday logon will be sent. |
SendAsIs(FixMessage)
Convenient method to send out FIX message based on the message type and message content.
Depending on implementation and configuration may send message immediately or put it in the outgoing queue either persistent or stateless.
The Engine sends the message as is.
If session is disposed no more messages should be send by session.
Declaration
bool SendAsIs(FixMessage message)
Parameters
| Type | Name | Description |
|---|---|---|
| FixMessage | message | the message content |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if message was send immediately, false - message was queued for later sending |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | if session is disposed |
| System.ArgumentException |
SendAsIs(FixMessage, FixSessionSendingType)
Convenient method to send out FIX message based on the message type and message content.
Depending on implementation and configuration may send message immediately or put it in the outgoing queue either persistent or stateless.
The Engine sends the message as is.
If session is disposed no more messages should be send by session.
Declaration
bool SendAsIs(FixMessage message, FixSessionSendingType optionMask)
Parameters
| Type | Name | Description |
|---|---|---|
| FixMessage | message | the message content |
| FixSessionSendingType | optionMask |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if message was send immediately, false - message was queued for later sending |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | if session is disposed |
| System.ArgumentException |
SendMessage(FixMessage)
Convenient method to send out user built FIX message. Depending on implementation and configuration may send message immediately or put it in the outgoing queue either persistent or stateless.
The Engine updates the footer and header in the message.
If session is disposed no more messages should be send by session.
Declaration
bool SendMessage(FixMessage message)
Parameters
| Type | Name | Description |
|---|---|---|
| FixMessage | message | the message |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if message was send immediately, false - message was queued for later sending |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | if session is disposed |
| System.ArgumentException |
SendMessage(FixMessage, FixSessionSendingType)
Convenient method to send out user built FIX message. Depending on implementation and configuration may send message immediately or put it in the outgoing queue either persistent or stateless.
The Engine updates the footer and header in the message.
If session is disposed no more messages should be send by session.
Declaration
bool SendMessage(FixMessage message, FixSessionSendingType optionMask)
Parameters
| Type | Name | Description |
|---|---|---|
| FixMessage | message | the message |
| FixSessionSendingType | optionMask |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if message was send immediately, false - message was queued for later sending |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | if session is disposed |
| System.ArgumentException |
SendMessage(String, FixMessage)
Convenient method to send out FIX message based on the message type and message content.
Depending on implementation and configuration may send message immediately or put it in the outgoing queue either persistent or stateless.
If the msgType is null, Engine sends the message as is;
If the msgType is "", Engine updates body length, sequence number, sending time and checksum fields;
Otherwise Engine wraps the content.
If session is disposed no more messages should be send by session.
Declaration
bool SendMessage(string msgType, FixMessage content)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | msgType | the message type (Tag 35 content) |
| FixMessage | content | the message content |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if message was send immediately, false - message was queued for later sending |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | if session is disposed |
| System.ArgumentException |
SendMessage(String, FixMessage, FixSessionSendingType)
Convenient method to send out FIX message based on the message type and message content.
Depending on implementation and configuration may send message immediately or put it in the outgoing queue either persistent or stateless.
If the msgType is null, Engine sends the message as is;
If the msgType is "", Engine updates body length, sequence number, sending time and checksum fields;
Otherwise Engine wraps the content.
If session is disposed no more messages should be send by session.
Declaration
bool SendMessage(string msgType, FixMessage content, FixSessionSendingType optionMask)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | msgType | the message type (Tag 35 content) |
| FixMessage | content | the message content |
| FixSessionSendingType | optionMask |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if message was send immediately, false - message was queued for later sending |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | if session is disposed |
| System.ArgumentException |
SendWithChanges(FixMessage, ChangesType, FixSessionSendingType)
Convenient method to send out FIX message based on the message type and message content.
Depending on implementation and configuration may send message immediately or put it in the outgoing queue either persistent or stateless.
The Engine sends the message as is.
If session is disposed no more messages should be send by session.
Declaration
bool SendWithChanges(FixMessage content, ChangesType allowedChangesType, FixSessionSendingType optionMask)
Parameters
| Type | Name | Description |
|---|---|---|
| FixMessage | content | the message content |
| ChangesType | allowedChangesType | the parameter takes the next values: |
| FixSessionSendingType | optionMask |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if message was send immediately, false - message was queued for later sending |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | if session is disposed |
| System.ArgumentException |
See Also
SendWithChanges(FixMessage, Nullable<ChangesType>)
Convenient method to send out FIX message based on the message type and message content.
Depending on implementation and configuration may send message immediately or put it in the outgoing queue either persistent or stateless.
The Engine sends the message as is.
If session is disposed no more messages should be send by session.
Declaration
bool SendWithChanges(FixMessage content, ChangesType? allowedChangesType)
Parameters
| Type | Name | Description |
|---|---|---|
| FixMessage | content | the message content |
| System.Nullable<ChangesType> | allowedChangesType | the parameter takes the next values: |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if message was send immediately, false - message was queued for later sending |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | if session is disposed |
| System.ArgumentException |
See Also
SetErrorHandler(IErrorHandler)
Sets error handler.
Declaration
void SetErrorHandler(IErrorHandler handler)
Parameters
| Type | Name | Description |
|---|---|---|
| IErrorHandler | handler | the error handler |
See Also
SetFixSessionListener(IFixSessionListener)
Sets IFIXSession listener to monitor session status and receive incoming messages.
Declaration
void SetFixSessionListener(IFixSessionListener listener)
Parameters
| Type | Name | Description |
|---|---|---|
| IFixSessionListener | listener | the user specified listener |
SetInSeqNum(Int64)
Declaration
void SetInSeqNum(long inSeqNum)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int64 | inSeqNum |
SetOutSeqNum(Int64)
Declaration
void SetOutSeqNum(long outSeqNum)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int64 | outSeqNum |
SetRejectMessageListener(IRejectMessageListener)
Sets reject listener.
Declaration
void SetRejectMessageListener(IRejectMessageListener listener)
Parameters
| Type | Name | Description |
|---|---|---|
| IRejectMessageListener | listener | the reject message listener |
See Also
SetSequenceNumbers(Int64, Int64)
Allows user to change sequences numbers for disconnected sessions.
Declaration
void SetSequenceNumbers(long inSeqNum, long outSeqNum)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int64 | inSeqNum | new incoming sequence number. If new value is < 0, then this parameter will be ignored. |
| System.Int64 | outSeqNum | new outgoing sequence number. If new value is < 0, then this parameter will be ignored. |
Exceptions
| Type | Condition |
|---|---|
| System.IO.IOException |
SetSlowConsumerListener(IFixSessionSlowConsumerListener)
Sets slow consumer message listener.
Declaration
void SetSlowConsumerListener(IFixSessionSlowConsumerListener slowConsumerListener)
Parameters
| Type | Name | Description |
|---|---|---|
| IFixSessionSlowConsumerListener | slowConsumerListener | slow consumer listener |