|Dialect Description||Table of Content||Dialect Exploration|
The dialect examples, described above, refer to engine-wide dialects. This means that specific dialects changes will affect each Engine session with only this FIX protocol dialect. Nevertheless, sometimes there is a need to use different FIX dialects in different FIX sessions within the same engine. OnixS .NET FIX Engine supports such per session dialects in the following manner.
To focus the scope of a dialect definition from engine-wise to session level, the dialect definition must be enhanced with additional attribute id:
<?xml version="1.0" encoding="utf-8"?> <Dialect xmlns="https://ref.onixs.biz/fix/dialects" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://ref.onixs.biz/fix/dialects https://ref.onixs.biz/fix/dialects/dialects-2.18.xsd"> <!-- Attribute 'id' tells OnixS .NET FIX Engine that dialect will be used in certain sessions only. It will not be used widely. --> <FIX version="4.0" id="Custom FIX"> <!-- Regular dialect description goes here. --> </FIX> </Dialect>
|When the defined dialect description has non-empty id attribute, then OnixS .NET FIX Engine will not use it for all sessions. Instead, such a dialect can be used for specific sessions only.|
In the source code, an instance of the Dialect class must be created. Its constructor accepts only one parameter which identifies the dialect you'd like to use for the session. Value of this parameter must be the same as in the XML description. Once an instance of Dialect is created, the FIX session can be initialized. the Session initialization is performed in the usual way with the only one difference: instead of supplying the version of the FIX protocol, the instance of the appropriate Dialect class must be passed. After that, the created session will operate using a specified FIX dialect.
using FIXForge.NET.FIX; Dialect customFIX = new Dialect("Custom FIX"); // Similar to how the Engine defines constants to certain FIX version, we // can define our namespace, in which all custom fields and values will reside. // Therefore, assume that CustomFIX is an example of such a namespace. Message orderOfCustomFIX = customFIX.CreateMessage(CustomFIX.MsgType.Order_Single); SetOrderFields(orderOfCustomFIX); orderOfCustomFIX.Validate(); sessionWithCustomFIX.Send(orderOfCustomFIX);
Imports FIXForge.NET.FIX Dim customFIX As New Dialect("Custom FIX") ' Similar to how the Engine defines constants to certain FIX version, we ' can define our namespace in which all custom fields and values will reside. ' Therefore, assume that CustomFIX is example of such a namespace. Dim orderOfCustomFIX As Message = customFIX.CreateMessage(CustomFIX.MsgType.Order_Single) SetOrderFields(orderOfCustomFIX) orderOfCustomFIX.Validate() sessionWithCustomFIX.Send(orderOfCustomFIX)