Пример #1
0
        private void Activate_Entrypoint(object state)
        {
            // REC: The service can only be activated if it is
            // currently in the closed state.
            if (_serviceState == VfxFixServiceStates.Service_State_Closed)
            {
                // REC: Adjust the service's current state:
                _serviceState = VfxFixServiceStates.Service_State_Opened;

                // REC: Adjust the service's current status:
                _serviceStatus = VfxFixServiceStatus.Service_Status_Opened;

                // REC: Dispatch the service started event:
                EventHandler <VfxFixServiceEventArgs> tmpDispatch_Started = EventDispatch;
                if (tmpDispatch_Started != null)
                {
                    VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Started, _serviceStatus);
                    tmpDispatch_Started(this, tmpArgs);
                }

                // REC: The service doesn't support a timed wait right now, so the
                // connection attempts start immediately:
                _serviceStatus = VfxFixServiceStatus.Service_Status_Connecting;
                EventHandler <VfxFixServiceEventArgs> tmpDispatch_Connecting = EventDispatch;
                if (tmpDispatch_Connecting != null)
                {
                    VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Started, _serviceStatus);
                    tmpDispatch_Connecting(this, tmpArgs);
                }

                // REC: Activate the IPC endpoint so that the
                // connection can be established to the peer:
                _ipcEndpoint.Activate();
            }
        }
Пример #2
0
        /// <summary>
        /// The HandleIpc_EventClosed event handler is invoked in
        /// response to the service being notified that the session
        /// has been disconnected from the peer system.
        /// </summary>
        /// <param name="sender">
        /// The IPC session that is dispatching the event.
        /// </param>
        /// <param name="args">
        /// The details of the IPC event being dispatched.
        /// </param>
        private void HandleIpc_EventClosed(object sender, VfxIpcEventArgs args)
        {
            lock (_synch)
            {
                // REC: The IPC session is no longer established:
                _ipcEstablished = false;

                // REC: Notify the FIX session that the peer system
                // is no longer connected:
                _fixSession.HandleDisconnect();

                // REC: Adjust the service's current status:
                _serviceStatus = VfxFixServiceStatus.Service_Status_Disconnected;
                EventHandler <VfxFixServiceEventArgs> tmpDispatch_Update = EventDispatch;
                if (tmpDispatch_Update != null)
                {
                    VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Updated, _serviceStatus);
                    tmpDispatch_Update(this, tmpArgs);
                }

                // REC: If the service is closing, then the disconnection
                // of the IPC endpoint is the last thing that needs to be
                // completed before dispatching the stopped event back up
                // to the service's owner/subscribers:
                if (_serviceState == VfxFixServiceStates.Service_State_Closing)
                {
                    // REC: Adjust the service's current state:
                    _serviceState = VfxFixServiceStates.Service_State_Closed;
                    // REC: Adjust the service's current status:
                    _serviceStatus = VfxFixServiceStatus.Service_Status_Closed;

                    EventHandler <VfxFixServiceEventArgs> tmpDispatch_Stopped = EventDispatch;
                    if (tmpDispatch_Stopped != null)
                    {
                        VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Stopped, _serviceStatus);
                        tmpDispatch_Stopped(this, tmpArgs);
                    }
                }
                else
                {
                    // REC: If the service is not configured to reconnect
                    // to the peer system, then it is now stopped:

                    // NOTE: Add reconnect logic here!

                    // REC: Adjust the service's current state:
                    _serviceState = VfxFixServiceStates.Service_State_Closed;
                    // REC: Adjust the service's current status:
                    _serviceStatus = VfxFixServiceStatus.Service_Status_Closed;

                    EventHandler <VfxFixServiceEventArgs> tmpDispatch_Stopped = EventDispatch;
                    if (tmpDispatch_Stopped != null)
                    {
                        VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Stopped, _serviceStatus);
                        tmpDispatch_Stopped(this, tmpArgs);
                    }
                }
            }
        }
Пример #3
0
        /// <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();
            }
        }
Пример #4
0
        /// <summary>
        /// The Shutdown_Entrypoint method is the asynchronous entrypoint
        /// for the shutdown operation. It is invoked by the thread pool.
        /// </summary>
        /// <param name="state"></param>
        private void Shutdown_Entrypoint(object state)
        {
            lock (_synch)
            {
                // REC: The service can only be shutdown if it
                // is currently in the opened state:
                if (_serviceState == VfxFixServiceStates.Service_State_Opened)
                {
                    // REC: Adjust the service's current state:
                    _serviceState = VfxFixServiceStates.Service_State_Closing;

                    // REC: Adjust the service's current status:
                    _serviceStatus = VfxFixServiceStatus.Service_Status_Closing;

                    // REC: Dispatch an 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: If the FIX session is established, it needs
                    // to be shutdown before the service can stop:
                    if (_fixEstablished == true)
                    {
                        _fixSession.HandleShutdown();
                    }
                    else if (_ipcEstablished == true)
                    {
                        _ipcEndpoint.Shutdown();
                    }
                    else
                    {
                        // REC: Neither the IPC session nor the FIX session
                        // are currently established, so the service should
                        // just dispatch the shutdown event to its owner:
                        _serviceState = VfxFixServiceStates.Service_State_Closed;

                        // REC: Adjust the service's status to reflect the new state:
                        _serviceStatus = VfxFixServiceStatus.Service_Status_Closed;

                        EventHandler <VfxFixServiceEventArgs> tmpDispatch = EventDispatch;
                        if (tmpDispatch != null)
                        {
                            VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Stopped, _serviceStatus);
                            tmpDispatch(this, tmpArgs);
                        }
                    }
                }
            }
        }
Пример #5
0
        /// <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);
                    }
                }
            }
        }
Пример #6
0
        private void Activate_Entrypoint(object state)
        {
            if (_serviceState == VfxFixServiceStates.Service_State_Closed)
            {
                _serviceState = VfxFixServiceStates.Service_State_Opened;

                _serviceStatus = VfxFixServiceStatus.Service_Status_Opened;

                // REC: Dispatch the service started event:
                EventHandler <VfxFixServiceEventArgs> tmpDispatch_Started = EventDispatch;
                if (tmpDispatch_Started != null)
                {
                    VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Started, _serviceStatus);
                    tmpDispatch_Started(this, tmpArgs);
                }

                _endpoint.Activate();
            }
        }
Пример #7
0
        private void Shutdown_Entrypoint(object state)
        {
            if (_serviceState == VfxFixServiceStates.Service_State_Opened)
            {
                // REC: Adjust the service's state:
                _serviceState = VfxFixServiceStates.Service_State_Closing;
                // REC: Adjust the service's status:
                _serviceStatus = VfxFixServiceStatus.Service_Status_Closing;

                // REC: Shutdown the IPC endpoint first:
                _endpoint.Shutdown();

                // REC: If there are any active FIX sessions, then they
                // need to be shutdown before the service can be shutdown.
                if (_mapFixSessions.Count > 0)
                {
                    // REC: Iterate over all of the sessions and instruct
                    // each one to shut itself down:
                    foreach (Guid key in _mapFixSessions.Keys)
                    {
                        _mapFixSessions[key].HandleShutdown();
                    }
                }
                else
                {
                    // REC: Adjust the service's current state:
                    _serviceState = VfxFixServiceStates.Service_State_Closed;
                    // REC: Adjust the service's current status:
                    _serviceStatus = VfxFixServiceStatus.Service_Status_Closed;
                    // REC: Dispatch the service stopped notification:
                    EventHandler <VfxFixServiceEventArgs> tmpDispatch = EventDispatch;
                    if (tmpDispatch != null)
                    {
                        VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Stopped, _serviceStatus);
                        tmpDispatch(this, tmpArgs);
                    }
                }
            }
        }
Пример #8
0
        private void Shutdown_Entrypoint(object state)
        {
            if (_serviceState == VfxFixServiceStates.Service_State_Opened)
            {
                // REC: Adjust the service's state:
                _serviceState = VfxFixServiceStates.Service_State_Closing;
                // REC: Adjust the service's status:
                _serviceStatus = VfxFixServiceStatus.Service_Status_Closing;

                // REC: Shutdown the IPC endpoint first:
                _endpoint.Shutdown();

                // REC: If there are any active FIX sessions, then they
                // need to be shutdown before the service can be shutdown.
                if (_mapFixSessions.Count > 0)
                {
                    // REC: Iterate over all of the sessions and instruct
                    // each one to shut itself down:
                    foreach (Guid key in _mapFixSessions.Keys)
                    {
                        _mapFixSessions[key].HandleShutdown();
                    }
                }
                else
                {
                    // REC: Adjust the service's current state:
                    _serviceState = VfxFixServiceStates.Service_State_Closed;
                    // REC: Adjust the service's current status:
                    _serviceStatus = VfxFixServiceStatus.Service_Status_Closed;
                    // REC: Dispatch the service stopped notification:
                    EventHandler<VfxFixServiceEventArgs> tmpDispatch = EventDispatch;
                    if (tmpDispatch != null)
                    {
                        VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Stopped, _serviceStatus);
                        tmpDispatch(this, tmpArgs);
                    }

                }
            }
        }
Пример #9
0
        private void Activate_Entrypoint(object state)
        {
            if (_serviceState == VfxFixServiceStates.Service_State_Closed)
            {
                _serviceState = VfxFixServiceStates.Service_State_Opened;

                _serviceStatus = VfxFixServiceStatus.Service_Status_Opened;

                // REC: Dispatch the service started event:
                EventHandler<VfxFixServiceEventArgs> tmpDispatch_Started = EventDispatch;
                if (tmpDispatch_Started != null)
                {
                    VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Started, _serviceStatus);
                    tmpDispatch_Started(this, tmpArgs);
                }

                _endpoint.Activate();
            }
        }
Пример #10
0
        /// <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);
                    }
                }
            }
        }
Пример #11
0
        /// <summary>
        /// The Shutdown_Entrypoint method is the asynchronous entrypoint
        /// for the shutdown operation. It is invoked by the thread pool.
        /// </summary>
        /// <param name="state"></param>
        private void Shutdown_Entrypoint(object state)
        {
            lock (_synch)
            {
                // REC: The service can only be shutdown if it
                // is currently in the opened state:
                if (_serviceState == VfxFixServiceStates.Service_State_Opened)
                {
                    // REC: Adjust the service's current state:
                    _serviceState = VfxFixServiceStates.Service_State_Closing;

                    // REC: Adjust the service's current status:
                    _serviceStatus = VfxFixServiceStatus.Service_Status_Closing;

                    // REC: Dispatch an 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: If the FIX session is established, it needs
                    // to be shutdown before the service can stop:
                    if(_fixEstablished == true)
                    {
                        _fixSession.HandleShutdown();
                    }
                    else if(_ipcEstablished == true)
                    {
                        _ipcEndpoint.Shutdown();
                    }
                    else
                    {
                        // REC: Neither the IPC session nor the FIX session
                        // are currently established, so the service should
                        // just dispatch the shutdown event to its owner:
                        _serviceState = VfxFixServiceStates.Service_State_Closed;

                        // REC: Adjust the service's status to reflect the new state:
                        _serviceStatus = VfxFixServiceStatus.Service_Status_Closed;

                        EventHandler<VfxFixServiceEventArgs> tmpDispatch = EventDispatch;
                        if (tmpDispatch != null)
                        {
                            VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Stopped, _serviceStatus);
                            tmpDispatch(this, tmpArgs);
                        }
                    }
                }
            }
        }
Пример #12
0
        /// <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();
            }
        }
Пример #13
0
        /// <summary>
        /// The HandleIpc_EventClosed event handler is invoked in
        /// response to the service being notified that the session
        /// has been disconnected from the peer system.
        /// </summary>
        /// <param name="sender">
        /// The IPC session that is dispatching the event.
        /// </param>
        /// <param name="args">
        /// The details of the IPC event being dispatched.
        /// </param>
        private void HandleIpc_EventClosed(object sender, VfxIpcEventArgs args)
        {
            lock (_synch)
            {
                // REC: The IPC session is no longer established:
                _ipcEstablished = false;

                // REC: Notify the FIX session that the peer system
                // is no longer connected:
                _fixSession.HandleDisconnect();

                // REC: Adjust the service's current status:
                _serviceStatus = VfxFixServiceStatus.Service_Status_Disconnected;
                EventHandler<VfxFixServiceEventArgs> tmpDispatch_Update = EventDispatch;
                if (tmpDispatch_Update != null)
                {
                    VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Updated, _serviceStatus);
                    tmpDispatch_Update(this, tmpArgs);
                }

                // REC: If the service is closing, then the disconnection
                // of the IPC endpoint is the last thing that needs to be
                // completed before dispatching the stopped event back up
                // to the service's owner/subscribers:
                if (_serviceState == VfxFixServiceStates.Service_State_Closing)
                {
                    // REC: Adjust the service's current state:
                    _serviceState = VfxFixServiceStates.Service_State_Closed;
                    // REC: Adjust the service's current status:
                    _serviceStatus = VfxFixServiceStatus.Service_Status_Closed;

                    EventHandler<VfxFixServiceEventArgs> tmpDispatch_Stopped = EventDispatch;
                    if (tmpDispatch_Stopped != null)
                    {
                        VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Stopped, _serviceStatus);
                        tmpDispatch_Stopped(this, tmpArgs);
                    }
                }
                else
                {
                    // REC: If the service is not configured to reconnect
                    // to the peer system, then it is now stopped:

                    // NOTE: Add reconnect logic here!

                    // REC: Adjust the service's current state:
                    _serviceState = VfxFixServiceStates.Service_State_Closed;
                    // REC: Adjust the service's current status:
                    _serviceStatus = VfxFixServiceStatus.Service_Status_Closed;

                    EventHandler<VfxFixServiceEventArgs> tmpDispatch_Stopped = EventDispatch;
                    if (tmpDispatch_Stopped != null)
                    {
                        VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Stopped, _serviceStatus);
                        tmpDispatch_Stopped(this, tmpArgs);
                    }
                }
            }
        }
Пример #14
0
        private void Activate_Entrypoint(object state)
        {
            // REC: The service can only be activated if it is
            // currently in the closed state.
            if (_serviceState == VfxFixServiceStates.Service_State_Closed)
            {
                // REC: Adjust the service's current state:
                _serviceState = VfxFixServiceStates.Service_State_Opened;

                // REC: Adjust the service's current status:
                _serviceStatus = VfxFixServiceStatus.Service_Status_Opened;

                // REC: Dispatch the service started event:
                EventHandler<VfxFixServiceEventArgs> tmpDispatch_Started = EventDispatch;
                if (tmpDispatch_Started != null)
                {
                    VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Started, _serviceStatus);
                    tmpDispatch_Started(this, tmpArgs);
                }

                // REC: The service doesn't support a timed wait right now, so the
                // connection attempts start immediately:
                _serviceStatus = VfxFixServiceStatus.Service_Status_Connecting;
                EventHandler<VfxFixServiceEventArgs> tmpDispatch_Connecting = EventDispatch;
                if (tmpDispatch_Connecting != null)
                {
                    VfxFixServiceEventArgs tmpArgs = new VfxFixServiceEventArgs(VfxFixServiceEventTypes.Event_Service_Started, _serviceStatus);
                    tmpDispatch_Connecting(this, tmpArgs);
                }

                // REC: Activate the IPC endpoint so that the
                // connection can be established to the peer:
                _ipcEndpoint.Activate();
            }
        }