Class Message
FIX message.
Inherited Members
Namespace: OnixS.Fix
Assembly: OnixS.Fix.Engine.dll
Syntax
public class Message : FieldSet, IDisposable, IMessage, IFieldSet, IEnumerable<Field>, IEnumerable
Constructors
Message(Message, MessageMemoryPool)
Creates the exact copy of the given message.
Declaration
public Message(Message message, MessageMemoryPool memoryPool = null)
Parameters
Type | Name | Description |
---|---|---|
Message | message | Source message to copy |
MessageMemoryPool | memoryPool | memory pool for pre-allocated objects |
Exceptions
Type | Condition |
---|---|
NullReferenceException | if |
Message(string, IMessageInfoDictionary, int, MessageMemoryPool)
Creates a message of the specified type.
Declaration
public Message(string messageType, IMessageInfoDictionary dictionary, int contentsCapacity = 128, MessageMemoryPool memoryPool = null)
Parameters
Type | Name | Description |
---|---|---|
string | messageType | Message type (the MsgType (tag 35) field value) |
IMessageInfoDictionary | dictionary | Dictionary to be used during the message construction |
int | contentsCapacity | size of buffer to store message field value |
MessageMemoryPool | memoryPool | memory pool for pre-allocated objects |
Message(string, ProtocolVersion, int, MessageMemoryPool)
Creates a message of the specified type.
Declaration
public Message(string messageType, ProtocolVersion version, int contentsCapacity = 128, MessageMemoryPool memoryPool = null)
Parameters
Type | Name | Description |
---|---|---|
string | messageType | Message type (the MsgType (tag 35) field value) |
ProtocolVersion | version | FIX Protocol version to be used during the message construction |
int | contentsCapacity | size of buffer to store message field value |
MessageMemoryPool | memoryPool | memory pool for pre-allocated objects |
Properties
Dictionary
Dictionary that was used to construct the message.
Declaration
public IMessageInfoDictionary Dictionary { get; }
Property Value
Type | Description |
---|---|
IMessageInfoDictionary |
IsFlatMessage
Returns true
if this is a FlatMessage instance, otherwise - false
.
Declaration
public bool IsFlatMessage { get; }
Property Value
Type | Description |
---|---|
bool |
|
Name
Message name.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
string | Message name |
SenderCompId
Assigned value used to identify firm sending message (the SenderCompID (tag=49) field value).
Declaration
public string SenderCompId { get; set; }
Property Value
Type | Description |
---|---|
string | SenderCompID |
SeqNum
Message sequence number (the MsgSeqNum (tag=34) field value).
Declaration
public int SeqNum { get; set; }
Property Value
Type | Description |
---|---|
int | Message sequence number |
TargetCompId
Assigned value used to identify receiving firm (the TargetCompID (tag=56) field value).
Declaration
public string TargetCompId { get; set; }
Property Value
Type | Description |
---|---|
string | TargetCompID |
Type
Returns message type (the MsgType (tag=35) field value).
Declaration
public string Type { get; }
Property Value
Type | Description |
---|---|
string | message type |
Version
Financial Interface eXchange (FIX) protocol version.
Declaration
public ProtocolVersion Version { get; }
Property Value
Type | Description |
---|---|
ProtocolVersion | The FIX protocol version of the message |
Methods
Assemble(ByteBuffer)
Declaration
public override void Assemble(ByteBuffer bb)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | bb |
Overrides
Clone()
Declaration
public Message Clone()
Returns
Type | Description |
---|---|
Message |
CompareType(char)
Returns true if the message type value is equal to the given char value, otherwise it returns false. The method can help to write GC-free code.
Declaration
public bool CompareType(char type)
Parameters
Type | Name | Description |
---|---|---|
char | type | Message type to compare |
Returns
Type | Description |
---|---|
bool | True if the message type value is equal to the given string value |
CompareType(string)
Returns true if the message type value is equal to the given string value, otherwise it returns false. The method can help to write GC-free code.
Declaration
public bool CompareType(string type)
Parameters
Type | Name | Description |
---|---|---|
string | type | Message type to compare |
Returns
Type | Description |
---|---|
bool | True if the message type value is equal to the given string value |
CopyFields(Message)
Copies all fields except the protocol version and message type from the given message.
Declaration
public void CopyFields(Message source)
Parameters
Type | Name | Description |
---|---|---|
Message | source | The source Message instance |
Equals(object)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object o)
Parameters
Type | Name | Description |
---|---|---|
object | o |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to the current object; otherwise, false. |
Overrides
GetEnumeratorOverRawMsg()
Returns an iterator over a raw FIX message as set of fields.
Note: Before any modifications to a FIX message the set of fields will be in the same order as they are received/parsed and will include duplicates.
Declaration
public virtual IEnumerator<Field> GetEnumeratorOverRawMsg()
Returns
Type | Description |
---|---|
IEnumerator<Field> | an Iterator. |
GetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for the current object. |
Overrides
GetMessage()
Declaration
protected override Message GetMessage()
Returns
Type | Description |
---|---|
Message |
Overrides
GetPosition(int)
Declaration
protected override int GetPosition(int tag)
Parameters
Type | Name | Description |
---|---|---|
int | tag |
Returns
Type | Description |
---|---|
int |
Overrides
GetStructuredMessage(IMessageInfoDictionary, MessageValidationFlags)
Returns the Message instance create from the given FlatMessage.
Declaration
public Message GetStructuredMessage(IMessageInfoDictionary dictionary, MessageValidationFlags messageParsingFlags)
Parameters
Type | Name | Description |
---|---|---|
IMessageInfoDictionary | dictionary | Dictionary to be used during the Message creation |
MessageValidationFlags | messageParsingFlags |
Returns
Type | Description |
---|---|
Message | Message instance |
Init(Message)
Initializes the message.
Declaration
public void Init(Message message)
Parameters
Type | Name | Description |
---|---|---|
Message | message | source FIX message to copy |
Exceptions
Type | Condition |
---|---|
NullReferenceException | if message == null |
Init(ReadOnlySpan<byte>, MessageValidationFlags)
Initializes the message.
Declaration
public void Init(ReadOnlySpan<byte> rawMsg, MessageValidationFlags parsingFlags = MessageValidationFlags.None)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | rawMsg | Raw FIX message in the tag=value form |
MessageValidationFlags | parsingFlags | Parsing flags |
Init(string, MessageValidationFlags)
Initializes the message.
Declaration
public void Init(string rawMessage, MessageValidationFlags parsingFlags = MessageValidationFlags.None)
Parameters
Type | Name | Description |
---|---|---|
string | rawMessage | Raw FIX message in the tag=value form |
MessageValidationFlags | parsingFlags | Parsing flags |
IsSessionLevel()
Returns true
if this is a session-level message, otherwise - false
.
Declaration
public bool IsSessionLevel()
Returns
Type | Description |
---|---|
bool |
|
Parse(FlatMessage, MessageInfoDictionaryManager, MessageValidationFlags, MessageMemoryPool)
Creates a Message instance on the base of the given FlatMessage object.
Declaration
public static Message Parse(FlatMessage flatMessage, MessageInfoDictionaryManager dictionaryManager, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type | Name | Description |
---|---|---|
FlatMessage | flatMessage | Source FlatMessage |
MessageInfoDictionaryManager | dictionaryManager | MessageInfoDictionaryManager to be used during the message construction |
MessageValidationFlags | parsingFlags | Parsing flags |
MessageMemoryPool | memoryPool | memory pool for pre-allocated objects |
Returns
Type | Description |
---|---|
Message |
Parse(FlatMessage, IMessageInfoDictionary, MessageValidationFlags, MessageMemoryPool)
Creates a Message instance on the base of the given FlatMessage object.
Declaration
public static Message Parse(FlatMessage flatMessage, IMessageInfoDictionary dictionary, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type | Name | Description |
---|---|---|
FlatMessage | flatMessage | Source FlatMessage |
IMessageInfoDictionary | dictionary | Dictionary to be used during the message construction |
MessageValidationFlags | parsingFlags | Parsing flags |
MessageMemoryPool | memoryPool | memory pool for pre-allocated objects |
Returns
Type | Description |
---|---|
Message |
Parse(byte[], int, int, MessageInfoDictionaryManager, MessageValidationFlags, MessageMemoryPool)
Parses the byte array and creates the corresponding message.
Declaration
public static Message Parse(byte[] rawMessage, int offset, int length, MessageInfoDictionaryManager dictionaryManager, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type | Name | Description |
---|---|---|
byte[] | rawMessage | FIX message in the tag=value form |
int | offset | message offset |
int | length | message length in bytes |
MessageInfoDictionaryManager | dictionaryManager | MessageInfoDictionaryManager to be used during the message construction |
MessageValidationFlags | parsingFlags | Parsing flags |
MessageMemoryPool | memoryPool | memory pool for pre-allocated objects |
Returns
Type | Description |
---|---|
Message |
Exceptions
Type | Condition |
---|---|
NullReferenceException | if rawMsg == null |
Parse(byte[], int, int, IMessageInfoDictionary, MessageValidationFlags, MessageMemoryPool)
Parses the byte array and creates the corresponding message.
Declaration
public static Message Parse(byte[] rawMessage, int offset, int length, IMessageInfoDictionary dictionary, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type | Name | Description |
---|---|---|
byte[] | rawMessage | FIX message in the tag=value form |
int | offset | message offset |
int | length | message length in bytes |
IMessageInfoDictionary | dictionary | Dictionary to be used during the message construction |
MessageValidationFlags | parsingFlags | Parsing flags |
MessageMemoryPool | memoryPool | memory pool for pre-allocated objects |
Returns
Type | Description |
---|---|
Message |
Parse(ReadOnlySpan<byte>, MessageInfoDictionaryManager, MessageValidationFlags, MessageMemoryPool)
Parses the byte span and creates the corresponding message instance.
Declaration
public static Message Parse(ReadOnlySpan<byte> rawMessage, MessageInfoDictionaryManager dictionaryManager, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | rawMessage | FIX message in the tag=value form |
MessageInfoDictionaryManager | dictionaryManager | MessageInfoDictionaryManager to be used during the message construction |
MessageValidationFlags | parsingFlags | Parsing flags |
MessageMemoryPool | memoryPool | memory pool for pre-allocated objects |
Returns
Type | Description |
---|---|
Message |
Exceptions
Type | Condition |
---|---|
NullReferenceException | if rawMessage == null |
Parse(ReadOnlySpan<byte>, IMessageInfoDictionary, MessageValidationFlags, MessageMemoryPool)
Parses the byte span and creates the corresponding message instance.
Declaration
public static Message Parse(ReadOnlySpan<byte> rawMessage, IMessageInfoDictionary dictionary, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | rawMessage | raw FIX message in the tag=value form |
IMessageInfoDictionary | dictionary | Dictionary to be used during the message construction |
MessageValidationFlags | parsingFlags | Parsing flags |
MessageMemoryPool | memoryPool | memory pool for pre-allocated objects |
Returns
Type | Description |
---|---|
Message |
Exceptions
Type | Condition |
---|---|
NullReferenceException | if rawMessage == null |
Parse(string, MessageInfoDictionaryManager, MessageValidationFlags, MessageMemoryPool)
Parses the raw FIX message string and creates the corresponding message.
Declaration
public static Message Parse(string rawMessage, MessageInfoDictionaryManager dictionaryManager, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type | Name | Description |
---|---|---|
string | rawMessage | raw FIX message in the tag=value form |
MessageInfoDictionaryManager | dictionaryManager | MessageInfoDictionaryManager to be used during the message construction |
MessageValidationFlags | parsingFlags | Parsing flags |
MessageMemoryPool | memoryPool | memory pool for pre-allocated objects |
Returns
Type | Description |
---|---|
Message |
Exceptions
Type | Condition |
---|---|
NullReferenceException | if rawMessage == null |
Parse(string, IMessageInfoDictionary, MessageValidationFlags, MessageMemoryPool)
Parses the string and creates the corresponding message.
Declaration
public static Message Parse(string rawMessage, IMessageInfoDictionary dictionary, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type | Name | Description |
---|---|---|
string | rawMessage | FIX message in the tag=value form |
IMessageInfoDictionary | dictionary | Dictionary to be used during the message construction |
MessageValidationFlags | parsingFlags | Parsing flags |
MessageMemoryPool | memoryPool | memory pool for pre-allocated objects |
Returns
Type | Description |
---|---|
Message |
Exceptions
Type | Condition |
---|---|
NullReferenceException | if rawMessage == null |
Parse(string, MessageValidationFlags, MessageMemoryPool)
Parses the string and creates the corresponding message.
Declaration
public static Message Parse(string rawMessage, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type | Name | Description |
---|---|---|
string | rawMessage | FIX message in the tag=value form |
MessageValidationFlags | parsingFlags | Parsing flags |
MessageMemoryPool | memoryPool | memory pool for pre-allocated objects |
Returns
Type | Description |
---|---|
Message |
Exceptions
Type | Condition |
---|---|
NullReferenceException | if rawMessage == null |
Parse(string, ProtocolVersion, MessageValidationFlags, MessageMemoryPool)
Parses the string and creates the corresponding message.
Declaration
public static Message Parse(string rawMessage, ProtocolVersion version, MessageValidationFlags parsingFlags = MessageValidationFlags.None, MessageMemoryPool memoryPool = null)
Parameters
Type | Name | Description |
---|---|---|
string | rawMessage | FIX message in the tag=value form |
ProtocolVersion | version | ProtocolVersion to be used during the message construction |
MessageValidationFlags | parsingFlags | Parsing flags |
MessageMemoryPool | memoryPool | memory pool for pre-allocated objects |
Returns
Type | Description |
---|---|
Message |
Exceptions
Type | Condition |
---|---|
NullReferenceException | if rawMessage == null |
Remove(int)
Removes the field.
Declaration
public override bool Remove(int tag)
Parameters
Type | Name | Description |
---|---|---|
int | tag | Tag number |
Returns
Type | Description |
---|---|
bool |
|
Overrides
Reset()
Resets to the clean, non-initialized state.
Declaration
public void Reset()
Set(int, byte[], int, int)
Sets the byte[] value.
Declaration
public override IFieldSet Set(int tag, byte[] value, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
int | tag | Tag number |
byte[] | value | Field value |
int | offset | Value offset |
int | length | Value length |
Returns
Type | Description |
---|---|
IFieldSet | This instance |
Overrides
Exceptions
Type | Condition |
---|---|
TagNotDefinedForThisMessageTypeException | if field with the given tag is not defined for this message and unknown fields are disabled |
ArgumentException |
|
Set(int, ReadOnlySpan<byte>)
Sets the ReadOnlySpan<T> value.
Declaration
public override IFieldSet Set(int tag, ReadOnlySpan<byte> value)
Parameters
Type | Name | Description |
---|---|---|
int | tag | Tag number |
ReadOnlySpan<byte> | value | Field value |
Returns
Type | Description |
---|---|
IFieldSet | This instance |
Overrides
Exceptions
Type | Condition |
---|---|
TagNotDefinedForThisMessageTypeException | if field with the given tag is not defined for this message and unknown fields are disabled |
Set(int, string)
Sets the string value.
Declaration
public override IFieldSet Set(int tag, string value)
Parameters
Type | Name | Description |
---|---|---|
int | tag | Tag number |
string | value | Field value |
Returns
Type | Description |
---|---|
IFieldSet | This instance |
Overrides
Exceptions
Type | Condition |
---|---|
TagNotDefinedForThisMessageTypeException | if field with the given tag is not defined for this message and unknown fields are disabled |
Set(int, StringBuilder)
Sets the string value.
Declaration
public override IFieldSet Set(int tag, StringBuilder value)
Parameters
Type | Name | Description |
---|---|---|
int | tag | Tag number |
StringBuilder | value | Field value |
Returns
Type | Description |
---|---|
IFieldSet | This instance |
Overrides
Exceptions
Type | Condition |
---|---|
TagNotDefinedForThisMessageTypeException | if field with the given tag is not defined for this message and unknown fields are disabled |
ToBytes(Span<byte>)
Serializes the message to the given byte span.
Declaration
public int ToBytes(Span<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
Span<byte> | buffer | Byte span to serialize the message content to |
Returns
Type | Description |
---|---|
int | The number of copied bytes if the given span is large enough; otherwise - a negative number, the absolute value of which is equal to the required size of the span |
ToJson(string, string)
Returns the JSON representation.
Declaration
public string ToJson(string indent = " ", string endOfLineDelimiter = "\n")
Parameters
Type | Name | Description |
---|---|---|
string | indent | |
string | endOfLineDelimiter |
Returns
Type | Description |
---|---|
string | JSON representation |
Remarks
For custom fields, a name is created by combining the Tag
prefix with the tag number.
ToXml(string, string)
Returns the XML representation.
Declaration
public string ToXml(string indent = " ", string endOfLineDelimiter = "\n")
Parameters
Type | Name | Description |
---|---|---|
string | indent | |
string | endOfLineDelimiter |
Returns
Type | Description |
---|---|
string | XML representation |
Remarks
For custom fields, a name is created by combining the Tag
prefix with the tag number.
UpdateBodyLengthAndCheckSum()
Updates the BodyLength
(tag 9
) and CheckSum
(tag 10
) fields.
Declaration
public void UpdateBodyLengthAndCheckSum()
Validate(MessageValidationFlags)
Validates the message.
Declaration
public void Validate(MessageValidationFlags validationFlags = MessageValidationFlags.StrictCreated)
Parameters
Type | Name | Description |
---|---|---|
MessageValidationFlags | validationFlags | Validation flags |
Exceptions
Type | Condition |
---|---|
ParserException | if the message is not valid |