![]() | Table of Content | Connecting using Custom Logon Message![]() |
Accepting FIX Session Without a Prior Creation of Session Object |
Sometimes there is a requirement to accept an incoming FIX session 'on the fly' without the prior creation of the Session object. This often happens when an unknown session-initiator is trying to connect to the Engine. For this reason, OnixS .NET FIX Engine exposes an ability to accept such connection by creating a generic session-acceptor. To take advantage of this feature, it is necessary to subscribe to the UnknownIncomingConnection event.
To accept the incoming connection, create a new Session object and call the LogonAsAcceptor() method to establish a connection. Required Session constructor parameters can be filled from the incoming logon message.
To decline the incoming connection, no action is needed. The only thing to do is to set the RejectReason parameter and the Engine will use it as text in logout message.
void run() { // .. Engine.Instance.UnknownIncomingConnection += new Engine.UnknownIncomingConnectionEventHandler(OnUnknownIncomingConnection); // .. } void OnUnknownIncomingConnection(Object sender, Engine.UnknownIncomingConnectionEventArgs args) { Message logonMessage = args.IncomingLogonMessage; Session createdSession = new Session(logonMessage[Tags.TargetCompID], logonMessage[Tags.SenderCompID], logonMessage.Dialect); Console.WriteLine("Accepting unknown incoming Session {0}.", createdSession); createdSession.LogonAsAcceptor(); }
void run() { // .. Engine.Instance.UnknownIncomingConnection += new Engine.UnknownIncomingConnectionEventHandler(OnUnknownIncomingConnection); // .. } void OnUnknownIncomingConnection(Object sender, Engine.UnknownIncomingConnectionEventArgs args) { args.RejectReason = "Session rejected."; }