/// <summary> /// matchMakerStateChanged is the event handler that takes care of detecting when the matchmaker /// gets removed from the data base. When this happens, there is no other option but to shutdown the /// platform /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void matchMakerStateChanged(object sender, LocalEndpointStateChangedEventArgs args) { AcdPlatform platform = _matchMaker._platform; AcdLogger logger = _matchMaker._logger; if (args.Reason == LocalEndpointStateTransitionReason.OwnerDisabledOrRemoved) { if (null != platform) { platform.BeginShutdown(ar => { platform.EndShutdown(ar); }, null); if (null != logger) { logger.Log("AcdAgentMatchMaker: Contact has been moved or removed, shutting down the application."); } } else { if (null != logger) { _matchMaker._logger.Log("AcdAgentMatchMaker: Contact has been moved or removed, but the platform is null. Cannot shut down the application."); } } } }
/// <summary> /// Releases the agent so that she can be allocated subsequently. /// </summary> internal void Deallocate(object owner) { lock (_syncRoot) { if (!_allocated) { _logger.Log("Agent is not allocated."); } else if (_owner == owner) // we verify that only the one, that allocated the agent, deallocates her { _logger.Log("Agent " + this.SignInAddress.ToString() + "was deallocated by " + owner.ToString()); _allocated = false; _allocationStatus = AgentAllocationStatus.NotAllocated; _activeIdleSince = DateTime.UtcNow; _asyncResult = null; _owner = null; _havePropertiesChanged = true; } else { _logger.Log("Agent can only be deallocated by its owner"); } } }