/// <summary> /// The OnSessionTxAppMessage callback is invoked by a session /// when it is ready to dispatch an application message to the /// peer session it's interacting with. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that is issuing the /// callback to the handler. /// </param> /// <param name="msg"> /// The application message that the session wants to have sent /// to its corresponding peer session. /// </param> public void OnSessionTxAppMessage(IVfxFixSession session, FixMessage msg) { // REC: Forward the app message to the application: _fixApplication.OnSessionTxAppMessage(_appSession, msg); // REC: Send the app message to the peer system: _ipcEndpoint.Send(null, new VfxMsgBlock(msg.ToString())); }
/// <summary> /// The OnSessionStarted callback method is invoked by an /// instance of a session when it is activated. /// </summary> /// <param name="session"> /// The FIX session that the event relates to. /// </param> public void OnSessionOpened(IVfxFixSession session) { if (_mapAppSessions.ContainsKey(session.InstanceId)) { IVfxFixAppSession appSession = _mapAppSessions[session.InstanceId]; _application.OnSessionOpened(appSession); } }
/// <summary> /// The OnSessionRxAppMessage callback is invoked by a session /// when it receives an application layer message from the peer /// session it's interacting with. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that is issuing the /// callback to the handler. /// </param> /// <param name="msg"> /// The application message that the session has received /// from its corresponding peer session. /// </param> public void OnSessionRxAppMessage(IVfxFixSession session, FixMessage msg) { if (_mapAppSessions.ContainsKey(session.InstanceId)) { IVfxFixAppSession appSession = _mapAppSessions[session.InstanceId]; _application.OnSessionRxAppMessage(appSession, msg); } }
/// <summary> /// The OnSessionLogon callback method is invoked by an /// instance of a session when it completes a logon with /// the peer system it's communicating with. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that is issuing /// the callback to the handler. /// </param> /// <param name="msg"> /// The FIX logon message (request or response) that was /// received from the peer session. /// </param> public void OnSessionLogon(IVfxFixSession session, FixMessage msg) { // REC: Forward the callback to the appropriate method // on the application's callback interface: if (_mapAppSessions.ContainsKey(session.InstanceId)) { IVfxFixAppSession appSession = _mapAppSessions[session.InstanceId]; _application.OnSessionLogon(appSession, msg); } }
/// <summary> /// The HandleIpc_EventOpened method is invoked in response /// to the IPC endpoint establishing a connection to the peer /// system that the service is interacting with. /// </summary> /// <param name="sender"> /// The VfxIpcEndpoint that dispatched the event. /// </param> /// <param name="args"> /// The details associated with the event. /// </param> private void HandleIpc_EventOpened(object sender, VfxIpcEventArgs args) { lock (_synch) { // REC: The IPC session is now established. _ipcEstablished = true; // REC: Adjust the service's current status: _serviceStatus = VfxFixServiceStatus.Service_Status_Opened; // REC: Dispatch the update to the service's subscribers: EventHandler <VfxFixServiceEventArgs> tmpDispatch_Update = EventDispatch; if (tmpDispatch_Update != null) { VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Updated, _serviceStatus); tmpDispatch_Update(this, tmpArgs); } // REC: Retrieve the version definition from the version // definition registry and determine what kind of session // needs to be created in order to handle the connection: IVfxFixVxRegistry vxRegistry = this._localServices.GetService(typeof(IVfxFixVxRegistry)) as IVfxFixVxRegistry; // REC: Create a new instance of a FIX session to handle // the communication between the server and the peer: IVfxFixSession fixSession = null; // REC: Check the version definition in order to tell if // this is a FIX 4.x or FIX 5.x service: VfxFixVxRecord vxRecord = vxRegistry.Get(this._sxVersion); if (vxRecord.Layer.ToLower().CompareTo("combined") == 0) { fixSession = new VfxFix4xClientSession(); } else { fixSession = new VfxFix5xClientSession(); } _fixSession = fixSession; // REC: Initialize the session: _fixSession.Init(this._localServices, this); // REC: Construct an instance of the session wrapper // for the FIX application and bind it to the session // implementation that has been created: _appSession = new VfxFixClientSession(_fixSession); // REC: Notify the FIX session implementation that it // has been connected to a peer system: _fixSession.HandleConnect(); } }
/// <summary> /// The OnSessionLogout callback is invoked by the underlying /// instance of a FIX session to notify the service that the /// session has logged out from the peer system. /// </summary> /// <param name="session"> /// The FIX session that is generating the callback. /// </param> /// <param name="msg"> /// The FIX logout message received from the peer. /// </param> public void OnSessionLogout(IVfxFixSession session, FixMessage msg) { lock (_synch) { // REC: The FIX session is no longer established. _fixEstablished = false; // REC: Forward the logout notification to the app: _fixApplication.OnSessionLogout(_appSession, msg); } }
/// <summary> /// The OnSessionLogon callback is invoked by the underlying /// instance of a FIX session to notify the service that the /// session has completed a FIX logon with the peer. /// </summary> /// <param name="session"> /// The FIX session that is generating the callback. /// </param> /// <param name="msg"> /// The FIX logon message received from the peer. /// </param> public void OnSessionLogon(IVfxFixSession session, FixMessage msg) { lock (_synch) { // REC: The FIX session has been established. _fixEstablished = true; // REC: Forward the logon notification to the app: _fixApplication.OnSessionLogon(_appSession, msg); } }
/// <summary> /// The HandleIpcDispatch_EventOpened event handler is invoked in /// response to a new session being established between a peer /// system and the endpoint associated with the service. /// </summary> /// <param name="sender"> /// The IPC endpoint that dispatched the event. /// </param> /// <param name="args"> /// The details of the event being dispatched. /// </param> private void HandleIpcDispatch_EventOpened(object sender, VfxIpcEventArgs args) { // REC: Create a new instance of a FIX session to handle // the communication between the server and the peer: IVfxFixSession fixSession = null; // REC: Retrieve the version definition from the version // definition registry and determine what kind of session // needs to be created in order to handle the connection: IVfxFixVxRegistry vxRegistry = this._localServices.GetService(typeof(IVfxFixVxRegistry)) as IVfxFixVxRegistry; // REC: Check the version definition in order to tell if // this is a FIX 4.x or FIX 5.x service: VfxFixVxRecord vxRecord = vxRegistry.Get(this._sxVersion); if (vxRecord.Layer.ToLower().CompareTo("combined") == 0) { fixSession = new VfxFix4xServerSession(); } else { fixSession = new VfxFix5xServerSession(); } // REC: Initialize the session: fixSession.Init(_localServices, this); // REC: Create an entry for the session in the // local session map: _mapFixSessions.Add(fixSession.InstanceId, fixSession); // REC: Bind the FIX session to the IPC session: _mapFixToIpc.Add(fixSession.InstanceId, args.Token); // REC: Bind the IPC session to the FIX session: _mapIpcToFix.Add(args.Token, fixSession.InstanceId); // REC: Create the application session container // that will be passed to the app implementation // when events are generated on the session: VfxFixServerSession appSession = new VfxFixServerSession(fixSession); // REC: Create a binding between the FIX session // and the application session so that events from // the FIX session can be correlated to the correct // application session when events are dispatched to // the user's FIX application instance: _mapAppSessions.Add(fixSession.InstanceId, appSession); // REC: Inform the session that a peer system // has been connected to it: fixSession.HandleConnect(); }
/// <summary> /// The OnSessionStopped event handler is invoked in response /// to the underlying FIX session being shutdown. /// </summary> /// <param name="session"> /// The FIX session that the event relates to. /// </param> public void OnSessionClosed(IVfxFixSession session) { lock (_synch) { _fixApplication.OnSessionClosed(_appSession); // REC: If the service is being closed and the FIX session // has just stopped, then the IPC handler can be shutdown: if (_serviceState == VfxFixServiceStates.Service_State_Closing) { _ipcEndpoint.Shutdown(); } } }
/// <summary> /// The OnSessionStopped callback method is invoked in response /// to an instance of a session being shutdown. /// </summary> /// <param name="session"> /// The FIX session that the event relates to. /// </param> public void OnSessionClosed(IVfxFixSession session) { // REC: Determine which application session corresponds to // the FIX session that the event is coming from and route // the appropriate notification to it. if (_mapAppSessions.ContainsKey(session.InstanceId)) { IVfxFixAppSession appSession = _mapAppSessions[session.InstanceId]; _application.OnSessionClosed(appSession); } // REC: If there is currently an IPC session in place // that corresponds to the FIX session, it needs to be // disconnected at this point: if (_mapFixToIpc.ContainsKey(session.InstanceId)) { _endpoint.Shutdown(_mapFixToIpc[session.InstanceId]); } else { // REC: Since the FIX session has been closed, it can // be removed from the active sessions map: if (_mapFixSessions.ContainsKey(session.InstanceId)) { _mapFixSessions.Remove(session.InstanceId); } } if (_serviceState == VfxFixServiceStates.Service_State_Closing) { if (_mapFixSessions.Count == 0) { // REC: Adjust the service's state: _serviceState = VfxFixServiceStates.Service_State_Closed; // REC: Adjust the service's status: _serviceStatus = VfxFixServiceStatus.Service_Status_Closed; // REC: Dispatch the closed event: EventHandler <VfxFixServiceEventArgs> tmpDispatch = EventDispatch; if (tmpDispatch != null) { VfxFixServiceEventArgs args = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Stopped, _serviceStatus); tmpDispatch(this, args); } } } }
/// <summary> /// The OnSessionTxAppMessage callback is invoked by a session /// when it is ready to dispatch an application message to the /// peer session it's interacting with. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that is issuing the /// callback to the handler. /// </param> /// <param name="msg"> /// The application message that the session wants to have sent /// to its corresponding peer session. /// </param> public void OnSessionTxAppMessage(IVfxFixSession session, FixMessage msg) { if (_mapAppSessions.ContainsKey(session.InstanceId)) { IVfxFixAppSession appSession = _mapAppSessions[session.InstanceId]; _application.OnSessionTxAppMessage(appSession, msg); // REC: Locate the IPC session identifier of the IPC session // that is associated with the service that is generating the // event and use that to send the message to the peer: if (_mapFixToIpc.ContainsKey(session.InstanceId)) { string ipcIdentifier = _mapFixToIpc[session.InstanceId]; _endpoint.Send(ipcIdentifier, new VfxMsgBlock(msg.ToString())); } } }
/// <summary> /// The OnSessionTxAppMessage callback is invoked by a session /// when it is ready to dispatch an application message to the /// peer session it's interacting with. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that is issuing the /// callback to the handler. /// </param> /// <param name="msg"> /// The application message that the session wants to have sent /// to its corresponding peer session. /// </param> public void OnSessionTxAppMessage(IVfxFixSession session, FixMessage msg) { // REC: Forward the app message to the application: _fixApplication.OnSessionTxAppMessage(_appSession, msg); // REC: Send the app message to the peer system: _ipcEndpoint.Send(null, new VfxMsgBlock(msg.ToString())); }
/// <summary> /// The OnSessionTimeout callback method is invoked by an /// instance of a session when it has not received any data /// from the peer during its configured timeout interval. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that is issuing the /// callback to the handler. /// </param> public void OnSessionTimeout(IVfxFixSession session) { this._ipcEndpoint.Shutdown(); }
/// <summary> /// The OnSessionRxAppMessage callback is invoked by a session /// when it receives an application layer message from the peer /// session it's interacting with. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that is issuing the /// callback to the handler. /// </param> /// <param name="msg"> /// The application message that the session has received /// from its corresponding peer session. /// </param> public void OnSessionRxAppMessage(IVfxFixSession session, FixMessage msg) { // REC: Forward the app message to the application: _fixApplication.OnSessionRxAppMessage(_appSession, msg); }
/// <summary> /// Initializes a new instance of the class with the /// specified parameters. /// </summary> /// <param name="session"> /// The FIX session that the server session encapsulates /// in order to forward requests that are made through the /// implementations of the IVfxFixAppSession methods. /// </param> public VfxFixServerSession(IVfxFixSession session) { _fixSession = session; }
/// <summary> /// The OnSessionTxAppMessage callback is invoked by a session /// when it is ready to dispatch an application message to the /// peer session it's interacting with. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that is issuing the /// callback to the handler. /// </param> /// <param name="msg"> /// The application message that the session wants to have sent /// to its corresponding peer session. /// </param> public void OnSessionTxAppMessage(IVfxFixSession session, FixMessage msg) { if (_mapAppSessions.ContainsKey(session.InstanceId)) { IVfxFixAppSession appSession = _mapAppSessions[session.InstanceId]; _application.OnSessionTxAppMessage(appSession, msg); // REC: Locate the IPC session identifier of the IPC session // that is associated with the service that is generating the // event and use that to send the message to the peer: if (_mapFixToIpc.ContainsKey(session.InstanceId)) { string ipcIdentifier = _mapFixToIpc[session.InstanceId]; _endpoint.Send(ipcIdentifier, new VfxMsgBlock(msg.ToString())); } } }
/// <summary> /// The OnSessionRxAppMessage callback is invoked by a session /// when it receives an application layer message from the peer /// session it's interacting with. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that is issuing the /// callback to the handler. /// </param> /// <param name="msg"> /// The application message that the session has received /// from its corresponding peer session. /// </param> public void OnSessionRxAppMessage(IVfxFixSession session, FixMessage msg) { if (_mapAppSessions.ContainsKey(session.InstanceId)) { IVfxFixAppSession appSession = _mapAppSessions[session.InstanceId]; _application.OnSessionRxAppMessage(appSession, msg); } }
/// <summary> /// The OnSessionLogon callback method is invoked by an /// instance of a session when it completes a logon with /// the peer system it's communicating with. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that is issuing /// the callback to the handler. /// </param> /// <param name="msg"> /// The FIX logon message (request or response) that was /// received from the peer session. /// </param> public void OnSessionLogon(IVfxFixSession session, FixMessage msg) { // REC: Forward the callback to the appropriate method // on the application's callback interface: if (_mapAppSessions.ContainsKey(session.InstanceId)) { IVfxFixAppSession appSession = _mapAppSessions[session.InstanceId]; _application.OnSessionLogon(appSession, msg); } }
/// <summary> /// Initializes a new instance of the class with the /// specified parameters. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that the client /// session forwards the appropriate requests to. /// </param> public VfxFixClientSession(IVfxFixSession session) { _fixSession = session; }
/// <summary> /// the OnSessionOpened callback is invoked by the underlying /// instance of a FIX session to notify the service that it has /// been started. At this point, the session is merely connected /// to the peer system and no messages have been exchanged. /// </summary> /// <param name="session"> /// The FIX session that the event relates to. /// </param> public void OnSessionOpened(IVfxFixSession session) { _fixApplication.OnSessionOpened(_appSession); }
/// <summary> /// The OnSessionTimeout callback method is invoked by an /// instance of a session when it has not received any data /// from the peer during its configured timeout interval. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that is issuing the /// callback to the handler. /// </param> public void OnSessionTimeout(IVfxFixSession session) { this._ipcEndpoint.Shutdown(); }
/// <summary> /// The OnSessionTimeout callback method is invoked by an /// instance of a session when it has not received any data /// from the peer during its configured timeout interval. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that is issuing the /// callback to the handler. /// </param> public void OnSessionTimeout(IVfxFixSession session) { //throw new NotImplementedException(); }
/// <summary> /// The OnSessionRxAppMessage callback is invoked by a session /// when it receives an application layer message from the peer /// session it's interacting with. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that is issuing the /// callback to the handler. /// </param> /// <param name="msg"> /// The application message that the session has received /// from its corresponding peer session. /// </param> public void OnSessionRxAppMessage(IVfxFixSession session, FixMessage msg) { // REC: Forward the app message to the application: _fixApplication.OnSessionRxAppMessage(_appSession, msg); }
/// <summary> /// The HandleIpc_EventOpened method is invoked in response /// to the IPC endpoint establishing a connection to the peer /// system that the service is interacting with. /// </summary> /// <param name="sender"> /// The VfxIpcEndpoint that dispatched the event. /// </param> /// <param name="args"> /// The details associated with the event. /// </param> private void HandleIpc_EventOpened(object sender, VfxIpcEventArgs args) { lock (_synch) { // REC: The IPC session is now established. _ipcEstablished = true; // REC: Adjust the service's current status: _serviceStatus = VfxFixServiceStatus.Service_Status_Opened; // REC: Dispatch the update to the service's subscribers: EventHandler<VfxFixServiceEventArgs> tmpDispatch_Update = EventDispatch; if (tmpDispatch_Update != null) { VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Updated, _serviceStatus); tmpDispatch_Update(this, tmpArgs); } // REC: Retrieve the version definition from the version // definition registry and determine what kind of session // needs to be created in order to handle the connection: IVfxFixVxRegistry vxRegistry = this._localServices.GetService(typeof(IVfxFixVxRegistry)) as IVfxFixVxRegistry; // REC: Create a new instance of a FIX session to handle // the communication between the server and the peer: IVfxFixSession fixSession = null; // REC: Check the version definition in order to tell if // this is a FIX 4.x or FIX 5.x service: VfxFixVxRecord vxRecord = vxRegistry.Get(this._sxVersion); if (vxRecord.Layer.ToLower().CompareTo("combined") == 0) { fixSession = new VfxFix4xClientSession(); } else { fixSession = new VfxFix5xClientSession(); } _fixSession = fixSession; // REC: Initialize the session: _fixSession.Init(this._localServices, this); // REC: Construct an instance of the session wrapper // for the FIX application and bind it to the session // implementation that has been created: _appSession = new VfxFixClientSession(_fixSession); // REC: Notify the FIX session implementation that it // has been connected to a peer system: _fixSession.HandleConnect(); } }
/// <summary> /// The OnSessionStopped event handler is invoked in response /// to the underlying FIX session being shutdown. /// </summary> /// <param name="session"> /// The FIX session that the event relates to. /// </param> public void OnSessionClosed(IVfxFixSession session) { lock (_synch) { _fixApplication.OnSessionClosed(_appSession); // REC: If the service is being closed and the FIX session // has just stopped, then the IPC handler can be shutdown: if (_serviceState == VfxFixServiceStates.Service_State_Closing) { _ipcEndpoint.Shutdown(); } } }
/// <summary> /// The OnSessionStopped callback method is invoked in response /// to an instance of a session being shutdown. /// </summary> /// <param name="session"> /// The FIX session that the event relates to. /// </param> public void OnSessionClosed(IVfxFixSession session) { // REC: Determine which application session corresponds to // the FIX session that the event is coming from and route // the appropriate notification to it. if (_mapAppSessions.ContainsKey(session.InstanceId)) { IVfxFixAppSession appSession = _mapAppSessions[session.InstanceId]; _application.OnSessionClosed(appSession); } // REC: If there is currently an IPC session in place // that corresponds to the FIX session, it needs to be // disconnected at this point: if (_mapFixToIpc.ContainsKey(session.InstanceId)) { _endpoint.Shutdown(_mapFixToIpc[session.InstanceId]); } else { // REC: Since the FIX session has been closed, it can // be removed from the active sessions map: if (_mapFixSessions.ContainsKey(session.InstanceId)) { _mapFixSessions.Remove(session.InstanceId); } } if (_serviceState == VfxFixServiceStates.Service_State_Closing) { if (_mapFixSessions.Count == 0) { // REC: Adjust the service's state: _serviceState = VfxFixServiceStates.Service_State_Closed; // REC: Adjust the service's status: _serviceStatus = VfxFixServiceStatus.Service_Status_Closed; // REC: Dispatch the closed event: EventHandler<VfxFixServiceEventArgs> tmpDispatch = EventDispatch; if (tmpDispatch != null) { VfxFixServiceEventArgs args = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Stopped, _serviceStatus); tmpDispatch(this, args); } } } }
/// <summary> /// The OnSessionLogon callback is invoked by the underlying /// instance of a FIX session to notify the service that the /// session has completed a FIX logon with the peer. /// </summary> /// <param name="session"> /// The FIX session that is generating the callback. /// </param> /// <param name="msg"> /// The FIX logon message received from the peer. /// </param> public void OnSessionLogon(IVfxFixSession session, FixMessage msg) { lock (_synch) { // REC: The FIX session has been established. _fixEstablished = true; // REC: Forward the logon notification to the app: _fixApplication.OnSessionLogon(_appSession, msg); } }
/// <summary> /// The OnSessionStarted callback method is invoked by an /// instance of a session when it is activated. /// </summary> /// <param name="session"> /// The FIX session that the event relates to. /// </param> public void OnSessionOpened(IVfxFixSession session) { if (_mapAppSessions.ContainsKey(session.InstanceId)) { IVfxFixAppSession appSession = _mapAppSessions[session.InstanceId]; _application.OnSessionOpened(appSession); } }
/// <summary> /// The OnSessionLogout callback is invoked by the underlying /// instance of a FIX session to notify the service that the /// session has logged out from the peer system. /// </summary> /// <param name="session"> /// The FIX session that is generating the callback. /// </param> /// <param name="msg"> /// The FIX logout message received from the peer. /// </param> public void OnSessionLogout(IVfxFixSession session, FixMessage msg) { lock (_synch) { // REC: The FIX session is no longer established. _fixEstablished = false; // REC: Forward the logout notification to the app: _fixApplication.OnSessionLogout(_appSession, msg); } }
/// <summary> /// The OnSessionTimeout callback method is invoked by an /// instance of a session when it has not received any data /// from the peer during its configured timeout interval. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that is issuing the /// callback to the handler. /// </param> public void OnSessionTimeout(IVfxFixSession session) { //throw new NotImplementedException(); }
/// <summary> /// the OnSessionOpened callback is invoked by the underlying /// instance of a FIX session to notify the service that it has /// been started. At this point, the session is merely connected /// to the peer system and no messages have been exchanged. /// </summary> /// <param name="session"> /// The FIX session that the event relates to. /// </param> public void OnSessionOpened(IVfxFixSession session) { _fixApplication.OnSessionOpened(_appSession); }
/// <summary> /// Initializes a new instance of the class with the /// specified parameters. /// </summary> /// <param name="session"> /// The FIX session that the server session encapsulates /// in order to forward requests that are made through the /// implementations of the IVfxFixAppSession methods. /// </param> public VfxFixServerSession(IVfxFixSession session) { _fixSession = session; }
/// <summary> /// Initializes a new instance of the class with the /// specified parameters. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that the client /// session forwards the appropriate requests to. /// </param> public VfxFixClientSession(IVfxFixSession session) { _fixSession = session; }