Publish the presence of a client over the network
Inheritance: IDisposable
Exemplo n.º 1
0
        /// <summary>
        /// Validates loaded license
        /// </summary>
        public virtual void AssertValidLicense(Action onValidLicense, bool turnOffDiscoveryClient = false, bool firstTime = false, bool forceUpdate = false)
        {
            LicenseAttributes.Clear();
            if (IsLicenseValid(firstTime,forceUpdate))
            {
                onValidLicense();

                if (MultipleLicenseUsageBehavior == MultipleLicenseUsage.AllowSameLicense)
                    return;

                if (nextLeaseTimer == null)
                    nextLeaseTimer = new Timer(LeaseLicenseAgain);
                if (!turnOffDiscoveryClient)
                {
                    try
                    {
                        discoveryHost.Start();
                    }
                    catch (Exception e)
                    {
                        // we explicitly don't want bad things to happen if we can't do that
                        Logger.ErrorException("Could not setup node discovery", e);
                    }
                    if (discoveryClient == null)
                    {
                        lock (this)
                        {
                            if (discoveryClient == null)
                            {
                                discoveryClient = new DiscoveryClient(senderId, UserId, Environment.MachineName, Environment.UserName);
                            }
                        }
                    }
                    discoveryClient.PublishMyPresence();

                }
                return;
            }

            Logger.Warn("Could not validate existing license\r\n{0}", License);
            throw new LicenseNotFoundException("Could not find a valid license.");
        }
        /// <summary>
        /// Validates loaded license
        /// </summary>
        public virtual void AssertValidLicense()
        {
            LicenseAttributes.Clear();
            if (HasExistingLicense())
            {
                if (this.DiscoveryEnabled)
                {
                    discoveryClient = new DiscoveryClient(senderId, UserId, Environment.MachineName, Environment.UserName);
                    discoveryClient.PublishMyPresence();
                }
                return;
            }

            Log.WarnFormat("Could not validate existing license\r\n{0}", License);
            throw new LicenseNotFoundException();
        }
        /// <summary>
        /// Validates loaded license
        /// </summary>
        public virtual void AssertValidLicense()
        {
            LicenseAttributes.Clear();
            if (HasExistingLicense())
            {
                if (DiscoveryEnabled)
                {
                    discoveryClient = new DiscoveryClient(senderId, UserId, Environment.MachineName, Environment.UserName);
                    discoveryClient.PublishMyPresence();
                }
                return;
            }

            throw new LicenseNotFoundException();
        }
		/// <summary>
		/// Validates loaded license
		/// </summary>
		public virtual void AssertValidLicense(Action onValidLicense)
		{
			LicenseAttributes.Clear();
			if (HasExistingLicense())
			{
				onValidLicense();
				
				if (MultipleLicenseUsageBehavior == MultipleLicenseUsage.AllowSameLicense)
					return; 

				try
				{
					discoveryHost.Start();
				}
				catch (Exception e)
				{
					// we explicitly don't want bad things to happen if we can't do that
					Logger.ErrorException("Could not setup node discovery", e);
				}

				discoveryClient = new DiscoveryClient(senderId, UserId, Environment.MachineName, Environment.UserName);
				discoveryClient.PublishMyPresence();
				return;
			}

			Logger.Warn("Could not validate existing license\r\n{0}", License);
			throw new LicenseNotFoundException("Could not find a valid license.");
		}