src/Foundation/ServiceModel/Gimela.ServiceModel.ManagedDiscovery/DiscoveryProxy/ServiceDiscoveryProxy.cs
/// <summary>
/// Override this method to handle an online announcement message.
/// </summary>
/// <param name="messageSequence">The discovery message sequence.</param>
/// <param name="endpointDiscoveryMetadata">The endpoint discovery metadata.</param>
/// <param name="callback">The callback delegate to call when the operation is completed.</param>
/// <param name="state">The user-defined state data.</param>
/// <returns>
/// A reference to the pending asynchronous operation.
/// </returns>
Override this method to handle an online announcement message.
Override this method to handle an online announcement message .
protected override IAsyncResult OnBeginOnlineAnnouncement(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, object state)
    {
      if (endpointDiscoveryMetadata == null)
      {
        throw new ArgumentNullException("endpointDiscoveryMetadata");
      }
      FindCriteria criteria = new FindCriteria(typeof(T));
      if (criteria.IsMatch(endpointDiscoveryMetadata))
      {
        if (!cache.Contains(endpointDiscoveryMetadata.Address.Uri))
        {
          cache.Add(endpointDiscoveryMetadata);
          Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Discovery proxy endpoint online : {0} - {1}", endpointDiscoveryMetadata.GetSpecifiedName(), endpointDiscoveryMetadata.Address.Uri));
        }
      }
      return new CompletedAsyncResult(callback, state);
    }
protected override IAsyncResult OnBeginOnlineAnnouncement ( DiscoveryMessageSequence messageSequence , EndpointDiscoveryMetadata endpointDiscoveryMetadata , AsyncCallback callback , object state ) { if ( endpointDiscoveryMetadata == null ) { throw new ArgumentNullException ( " " ) ; } FindCriteria criteria = new FindCriteria ( typeof ( T ) ) ; if ( criteria . IsMatch ( endpointDiscoveryMetadata ) ) { if ( ! cache . Contains ( endpointDiscoveryMetadata . Address . Uri ) ) { cache . Add ( endpointDiscoveryMetadata ) ; Console . WriteLine ( string . Format ( CultureInfo . InvariantCulture , " " , endpointDiscoveryMetadata . GetSpecifiedName ( ) , endpointDiscoveryMetadata . Address . Uri ) ) ; } } return new CompletedAsyncResult ( callback , state ) ; }
Override this method to handle an online announcement message.
Override this method to handle an online announcement message .
// 指定类型的服务上线
A reference to the pending asynchronous operation.
A reference to the pending asynchronous operation .
messageSequence
DiscoveryMessageSequence
The discovery message sequence.
The discovery message sequence .
endpointDiscoveryMetadata
EndpointDiscoveryMetadata
The endpoint discovery metadata.
The endpoint discovery metadata .
callback
AsyncCallback
The callback delegate to call when the operation is completed.
The callback delegate to call when the operation is completed .
state
object
The user-defined state data.
The user - defined state data .