aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Properties/Settings.settings
blob: 033d7a5e9e2266753180f4e3a9299f575046701e (plain)
1
2
3
4
5
6
7
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
  <Profiles>
    <Profile Name="(Default)" />
  </Profiles>
  <Settings />
</SettingsFile>
me.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using Google.Protobuf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Tango.Transport.Discovery
{
    /// <summary>
    /// Represents a discovery client 
    /// </summary>
    /// <seealso cref="System.EventArgs" />
    public class DiscoveredService<DiscoveryMessage> : EventArgs where DiscoveryMessage : IMessage
    {
        private Func<bool> _validateDiscoveryAction;

        /// <summary>
        /// Gets or sets the discovery message.
        /// </summary>
        public DiscoveryMessage Message { get; set; }

        /// <summary>
        /// Gets or sets the service IP address.
        /// </summary>
        public String Address { get; set; }

        /// <summary>
        /// Gets or sets the name of the host.
        /// </summary>
        public String HostName { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="DiscoveredService{DiscoveryMessage}"/> class.
        /// </summary>
        /// <param name="address">The address.</param>
        /// <param name="message">The message.</param>
        /// <param name="hostName">The host name.</param>
        public DiscoveredService(String address, String hostName, DiscoveryMessage message, Func<bool> validateDiscoveryAction)
        {
            HostName = hostName;
            Address = address;
            Message = message;
            _validateDiscoveryAction = validateDiscoveryAction;
        }

        /// <summary>
        /// Validates the service existence using a TCP request.
        /// </summary>
        /// <returns></returns>
        public bool ValidateServiceExistence()
        {
            return _validateDiscoveryAction();
        }
    }
}