OnixS C++ FIX Engine 2.79.1.0
Connecting using Custom Logon Message

As is well known, when a session is being established, it sends a Logon message as is defined by the FIX Standard. However, in specific use contexts there may be a need to include additional information to the counterparty which is not specified by the Standard. One of the common use case examples is when the counterparty requires authentication attributes like username and password. OnixS C++ FIX Engine supports this capability through the additional overload of the OnixS::FIX::Session class - OnixS::FIX::Session::logonAsInitiator.

Example

A lot of trading systems based on version 4.2 of the FIX Protocol require username (tag #553) and password (tag #554) fields to be included in the Logon message. Both fields do not exist in version 4.2 of the formal Standard. These fields were implemented in later versions of the FIX Protocol standards releases. The following sample demonstrates the solution for this typical situation. In particular, it sends the Logon message with the additional fields which are required by the counterparty.

#include <OnixS/FIXEngine.h>

using namespace OnixS::FIX;
using namespace OnixS::FIX::FIX43;

// Session attributes.

const string SENDER_COMP_ID = "CustomLogonMessage_SND";
const string TARGET_COMP_ID = "CustomLogonMessage_TRG";

const Version VERSION = FIX_42;
const int HBI = 30;

const string USERNAME = "USER_NAME";
const string PASSWORD = "PASSWORD";

// Connection settings.

string host = "localhost";
int port = Engine::instance()->getListenPort();

// Here we go..

ISessionListener defaultListener;

Session initiator(TARGET_COMP_ID, SENDER_COMP_ID, VERSION, &defaultListener);

Message logonMsgWithAuthentication(Values::MsgType::Logon, VERSION);

// Username as well as Password field was first invented in FIX 4.3. 
// Therefore tag value should be taken from a OnixS::FIX::FIX43 namespace.

logonMsgWithAuthentication.set(Tags::Username, USERNAME);
logonMsgWithAuthentication.set(Tags::Password, PASSWORD);

initiator.logonAsInitiator(host, port, HBI, &logonMsgWithAuthentication);

// That's all special. Regular session manipulating goes afterwards..