public DiscoveryMessageSequence GetMessageSequence(EndpointDiscoveryMetadata endpointDiscoveryMetadata) { if (endpointDiscoveryMetadata == null) { throw FxTrace.Exception.ArgumentNull("endpointDiscoveryMetadata"); } DiscoveryMessageSequence messageSequence = null; if (!this.messageSequenceTable.TryGetValue(endpointDiscoveryMetadata, out messageSequence)) { throw FxTrace.Exception.Argument("endpointDiscoveryMetadata", SR2.DiscoveryFindResponseMessageSequenceNotFound); } return(messageSequence); }
//----------------------------------------------------- // Online Announcements //----------------------------------------------------- #region OnlineAnnouncement /// <summary> /// Handles 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> protected override IAsyncResult OnBeginOnlineAnnouncement(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, object state) { var tcs = new TaskCompletionSource <object>(state); // Start a background task that will process anounncement Task.Factory.StartNew(() => { // Create and executy all Online announcement tasks var tasks = _onlineTaskFactories.AsParallel() .Select((factory) => { return(factory.Create(new DiscoveryMessageSequence[] { messageSequence }, new EndpointDiscoveryMetadata[] { endpointDiscoveryMetadata })); }) .ToArray(); // TODO: Decide if we want to wait for completion of all tasks // Task.WaitAll(tasks); tcs.SetResult(null); callback(tcs.Task); }); return(tcs.Task); }
protected abstract IAsyncResult BeginSendProxyAnnouncement( TResponseChannel responseChannel, DiscoveryMessageSequence discoveryMessageSequence, EndpointDiscoveryMetadata proxyEndpointDiscoveryMetadata, AsyncCallback callback, object state);
protected abstract IAsyncResult BeginSendResolveResponse( TResponseChannel responseChannel, DiscoveryMessageSequence discoveryMessageSequence, EndpointDiscoveryMetadata matchingEndpoint, AsyncCallback callback, object state);
internal void AddDiscoveredEndpoint(EndpointDiscoveryMetadata endpointDiscoveryMetadata, DiscoveryMessageSequence messageSequence) { this.messageSequenceTable.Add(endpointDiscoveryMetadata, messageSequence); this.endpoints.Add(endpointDiscoveryMetadata); }
/// <summary> /// Handles Offline announcements. /// </summary> /// <param name="messageSequence">The array discovery message sequence.</param> /// <param name="endpointDiscoveryMetadata">The array of endpoint discovery metadata.</param> protected abstract void OnOfflineAnnouncement(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata);
protected abstract TResponseMessage GetResolveResponse( DiscoveryMessageSequence discoveryMessageSequence, EndpointDiscoveryMetadata matchingEndpoints);
protected abstract IAsyncResult OnBeginOfflineAnnouncement( DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, object state);
internal FindProgressChangedEventArgs(int progressPercentage, object userState, EndpointDiscoveryMetadata endpointDiscoveryMetadata, DiscoveryMessageSequence messageSequence) : base(progressPercentage, userState) { this.endpointDiscoveryMetadata = endpointDiscoveryMetadata; this.messageSequence = messageSequence; }
internal FindProgressChangedEventArgs(EndpointDiscoveryMetadata metadata, DiscoveryMessageSequence sequence, int progressPercentage, object userState) : base(progressPercentage, userState) { EndpointDiscoveryMetadata = metadata; MessageSequence = sequence; }
internal ResolveResponse(EndpointDiscoveryMetadata metadata, DiscoveryMessageSequence sequence) { EndpointDiscoveryMetadata = metadata; MessageSequence = sequence; }
internal AnnouncementEventArgs(EndpointDiscoveryMetadata metadata, DiscoveryMessageSequence queue) { EndpointDiscoveryMetadata = metadata; MessageSequence = queue; }
protected abstract TResponseMessage GetProbeResponse( DiscoveryMessageSequence discoveryMessageSequence, Collection <EndpointDiscoveryMetadata> matchingEndpoints);