Exemple #1
0
        protected override IAsyncResult OnBeginOfflineAnnouncement(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, object state)
        {
            try
            {
                if (endpointDiscoveryMetadata == null)
                {
                    throw new ArgumentNullException("endpointDiscoveryMetadata");
                }

                // We care only about ISimpleChatService services
                FindCriteria criteria = new FindCriteria(typeof(ISimpleChatService));

                if (criteria.IsMatch(endpointDiscoveryMetadata))
                {
                    endpointDiscoveryMetadata.WriteLine("Removing");
                    Cache.Remove(endpointDiscoveryMetadata.Address.Uri);
                }
            }
            catch (KeyNotFoundException)
            {
                // No problem if it does not exist in the cache
            }

            return new CompletedAsyncResult(callback, state);
        }
Exemple #2
0
        protected override IAsyncResult OnBeginOnlineAnnouncement(DiscoveryMessageSequence messageSequence,
                                                EndpointDiscoveryMetadata endpointDiscoveryMetadata,
                                                AsyncCallback callback,
                                                object state)
        {
            if (endpointDiscoveryMetadata == null)
            {
                throw new ArgumentNullException("endpointDiscoveryMetadata");
            }

            // We care only about ISimpleChatService services
            FindCriteria criteria = new FindCriteria(typeof(ISimpleChatService));

            if (criteria.IsMatch(endpointDiscoveryMetadata))
            {
                endpointDiscoveryMetadata.WriteLine("Adding");
                Cache.Add(endpointDiscoveryMetadata);
            }

            return new CompletedAsyncResult(callback, state);
        }