public override ResponseHeader FindServers(
RequestHeader requestHeader,
string endpointUrl,
StringCollection localeIds,
StringCollection serverUris,
out ApplicationDescriptionCollection servers)
{
servers = new ApplicationDescriptionCollection();
ValidateRequest(requestHeader);
lock (m_lock)
{
// parse the url provided by the client.
IList<BaseAddress> baseAddresses = BaseAddresses;
Uri parsedEndpointUrl = Utils.ParseUri(endpointUrl);
if (parsedEndpointUrl != null)
{
baseAddresses = FilterByEndpointUrl(parsedEndpointUrl, baseAddresses);
}
// check if nothing to do.
if (baseAddresses.Count == 0)
{
servers = new ApplicationDescriptionCollection();
return CreateResponse(requestHeader, StatusCodes.Good);
}
// build list of unique servers.
Dictionary<string,ApplicationDescription> uniqueServers = new Dictionary<string,ApplicationDescription>();
foreach (EndpointDescription description in GetEndpoints())
{
ApplicationDescription server = description.Server;
// skip servers that have been processed.
if (uniqueServers.ContainsKey(server.ApplicationUri))
{
continue;
}
// check client is filtering by server uri.
if (serverUris != null && serverUris.Count > 0)
{
if (!serverUris.Contains(server.ApplicationUri))
{
continue;
}
}
// localize the application name if requested.
LocalizedText applicationName = server.ApplicationName;
if (localeIds != null && localeIds.Count > 0)
{
applicationName = m_serverInternal.ResourceManager.Translate(localeIds, applicationName);
}
// get the application description.
ApplicationDescription application = TranslateApplicationDescription(
parsedEndpointUrl,
server,
baseAddresses,
applicationName);
uniqueServers.Add(server.ApplicationUri, application);
// add to list of servers to return.
servers.Add(application);
}
}
return CreateResponse(requestHeader, StatusCodes.Good);
}