예제 #1
0
        /// <summary>
        /// Handles the new incoming heartbeat
        /// </summary>
        /// <param name="heartbeat">TradeHub Heartbeat Message</param>
        public void Update(HeartbeatMessage heartbeat)
        {
            try
            {
                HeartBeatProcessor processor;
                if (!_heartBeatProcessors.TryGetValue(heartbeat.ApplicationId, out processor))
                {
                    processor = new HeartBeatProcessor(heartbeat, _heartbeatValidationInterval,
                                                       _heartbeatResponseInterval);

                    // Register Heartbeat Processor Events
                    RegisterProcessorEvents(processor);

                    // Update Heartbeat Processors Map
                    _heartBeatProcessors.TryAdd(heartbeat.ApplicationId, processor);

                    // Add MDE-Server Heartbeat Interval
                    heartbeat.HeartbeatInterval = _heartbeatResponseInterval;

                    // Send Heartbeat Response
                    OnProcessorResponse(heartbeat);
                }

                // Update Heartbeat Processor
                processor.Update();
            }
            catch (Exception exception)
            {
                Logger.Error(exception, _type.FullName, "Update");
            }
        }
예제 #2
0
 /// <summary>
 /// Unhooks HeartBeat Processor Events
 /// </summary>
 private void UnregisterProcessorEvents(HeartBeatProcessor processor)
 {
     processor.Disconnect -= OnProcessorDisconnect;
     processor.Response   -= OnProcessorResponse;
 }