Exemplo n.º 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);
        }
 internal AnnouncementEventArgs(
     DiscoveryMessageSequence messageSequence, 
     EndpointDiscoveryMetadata endpointDiscoveryMetadata)
 {
     this.MessageSequence = messageSequence;
     this.EndpointDiscoveryMetadata = endpointDiscoveryMetadata;
 }
 internal FindProgressChangedEventArgs(int progressPercentage, object userState,
     EndpointDiscoveryMetadata endpointDiscoveryMetadata, DiscoveryMessageSequence messageSequence)
     : base(progressPercentage, userState)
 {
     this.endpointDiscoveryMetadata = endpointDiscoveryMetadata;
     this.messageSequence = messageSequence;
 }
Exemplo n.º 4
0
		protected override IAsyncResult OnBeginOfflineAnnouncement(
			DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata,
			AsyncCallback callback, object state)
		{
			implementation.RemoveEndpoint(endpointDiscoveryMetadata);
			return new SynchronousResult(callback, state);
		}
Exemplo n.º 5
0
 // OnBeginOnlineAnnouncement method is called when a Hello message is received by the Proxy
 protected override IAsyncResult OnBeginOnlineAnnouncement(DiscoveryMessageSequence messageSequence,
     EndpointDiscoveryMetadata endpointDiscoveryMetadata,
     AsyncCallback callback, object state)
 {
     _logger.Log("OnBeginOnlineAnnouncement()", LogLevel.Debug);
     _provider.Add(endpointDiscoveryMetadata);
     return new OnOnlineAnnouncementAsyncResult(callback, state);
 }
Exemplo n.º 6
0
 public static ByeMessage11 Create(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata)
 {
     return new ByeMessage11()
         {
             MessageSequence = DiscoveryMessageSequence11.FromDiscoveryMessageSequence(messageSequence),
             Bye = EndpointDiscoveryMetadata11.FromEndpointDiscoveryMetadata(endpointDiscoveryMetadata)
         };
 }
 internal static ByeMessageApril2005 Create(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata)
 {
     return new ByeMessageApril2005()
         {
             MessageSequence = DiscoveryMessageSequenceApril2005.FromDiscoveryMessageSequence(messageSequence),
             Bye = EndpointDiscoveryMetadataApril2005.FromEndpointDiscoveryMetadata(endpointDiscoveryMetadata)
         };
 }
 public static HelloMessageCD1 Create(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata)
 {
     return new HelloMessageCD1()
         {
             MessageSequence = DiscoveryMessageSequenceCD1.FromDiscoveryMessageSequence(messageSequence),
             Hello = EndpointDiscoveryMetadataCD1.FromEndpointDiscoveryMetadata(endpointDiscoveryMetadata)
         };
 }
 public static HelloMessageApril2005 Create(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata)
 {
     return new HelloMessageApril2005()
         {
             MessageSequence = DiscoveryMessageSequenceApril2005.FromDiscoveryMessageSequence(messageSequence),
             Hello = EndpointDiscoveryMetadataApril2005.FromEndpointDiscoveryMetadata(endpointDiscoveryMetadata)
         };
 }
 public static DiscoveryMessageSequence11 FromDiscoveryMessageSequence(DiscoveryMessageSequence discoveryMessageSequence)
 {
     if (discoveryMessageSequence == null)
     {
         throw FxTrace.Exception.ArgumentNull("discoveryMessageSequence");
     }
     return new DiscoveryMessageSequence11(discoveryMessageSequence);
 }
 public static ProbeMatchesMessageCD1 Create(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata)
 {
     return new ProbeMatchesMessageCD1()
         {
             MessageSequence = DiscoveryMessageSequenceCD1.FromDiscoveryMessageSequence(messageSequence),
             ProbeMatches = ProbeMatchesCD1.Create(endpointDiscoveryMetadata)
         };
 }
 public static ProbeMatchesMessageApril2005 Create(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata)
 {
     return new ProbeMatchesMessageApril2005()
         {
             MessageSequence = DiscoveryMessageSequenceApril2005.FromDiscoveryMessageSequence(messageSequence),
             ProbeMatches = ProbeMatchesApril2005.Create(endpointDiscoveryMetadata)
         };
 }
Exemplo n.º 13
0
 //OfflineAnnouncement
 protected override IAsyncResult OnBeginOfflineAnnouncement(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, object state)
 {
     if (this.Endpoints.ContainsKey(endpointDiscoveryMetadata.Address))
     {
         this.Endpoints.Remove(endpointDiscoveryMetadata.Address);
     }
     return new DiscoveryAsyncResult(callback, state);
 }
 public static ResolveMatchesMessage11 Create(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata)
 {
     return new ResolveMatchesMessage11()
         {
             MessageSequence = DiscoveryMessageSequence11.FromDiscoveryMessageSequence(messageSequence),
             ResolveMatches = ResolveMatches11.Create(endpointDiscoveryMetadata)
         };
 }
		bool PushQueueItem (DiscoveryMessageSequence seq)
		{
			if (sequences.Contains (seq))
				return false;
			sequences.Enqueue (seq);
			if (sequences.Count > 20)
				sequences.Dequeue ();
			return true;
		}
 public static ProbeMatchesMessage11 Create(DiscoveryMessageSequence messageSequence, 
     Collection<EndpointDiscoveryMetadata> endpointDiscoveryMetadatas)
 {
     return new ProbeMatchesMessage11()
         {
             MessageSequence = DiscoveryMessageSequence11.FromDiscoveryMessageSequence(messageSequence),
             ProbeMatches = ProbeMatches11.Create(endpointDiscoveryMetadatas)
         };
 }
        protected override IAsyncResult OnBeginOnlineAnnouncement(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, object state)
        {
            lock (this.onlineServices)
            {
                this.onlineServices[endpointDiscoveryMetadata.Address] =
                    endpointDiscoveryMetadata;
                PrintTrace(endpointDiscoveryMetadata, "Adding");
            }

            return response;
        }
Exemplo n.º 18
0
 protected override IAsyncResult BeginSendFindResponse(
     IDiscoveryResponseContract11 responseChannel,
     DiscoveryMessageSequence discoveryMessageSequence,
     EndpointDiscoveryMetadata matchingEndpoint,
     AsyncCallback callback,
     object state)
 {
     return(responseChannel.BeginProbeMatchOperation(
                ProbeMatchesMessage11.Create(
                    discoveryMessageSequence,
                    matchingEndpoint),
                callback,
                state));
 }
 protected override IAsyncResult BeginSendProxyAnnouncement(
     IDiscoveryResponseContract11 responseChannel,
     DiscoveryMessageSequence discoveryMessageSequence,
     EndpointDiscoveryMetadata proxyEndpointDiscoveryMetadata,
     AsyncCallback callback,
     object state)
 {
     return(responseChannel.BeginHelloOperation(
                HelloMessage11.Create(
                    discoveryMessageSequence,
                    proxyEndpointDiscoveryMetadata),
                callback,
                state));
 }
        protected override IAsyncResult OnBeginOfflineAnnouncement(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, object state)
        {
            if (this.onlineServices.Count > 0)
            {
                lock (this.onlineServices)
                {
                    this.onlineServices.Remove(endpointDiscoveryMetadata.Address);
                    PrintTrace(endpointDiscoveryMetadata, "Removing");
                }
            }

            return response;

        }
Exemplo n.º 21
0
        protected override IAsyncResult OnBeginOnlineAnnouncement(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, object state)
        {
            var context = _plugins.Invoke(() => new AnnouncementPluginContext(endpointDiscoveryMetadata), (plugin, e) => plugin.BeforeBeginOnlineAnnouncement(e), true);

            if (!context.Cancel)
            {
                if (!endpointDiscoveryMetadata.IsIgnored())
                {
                    _metadataProvider.AddEndpointMetadata(endpointDiscoveryMetadata);
                }
            }

            _plugins.Invoke(() => new AnnouncementPluginContext(context.Metadata), (plugin, e) => plugin.AfterBeginOnlineAnnouncement(e), true);
            return new OnOnlineAnnouncementAsyncResult(callback, state);
        }
Exemplo n.º 22
0
		protected virtual IAsyncResult OnBeginOnlineAnnouncement (DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, object state)
		{
			// FIXME: this is a workaround for (similar to) bug #633945.
			switch (Environment.OSVersion.Platform) {
			case PlatformID.Unix:
			case PlatformID.MacOSX:
				if (online == null)
					online = new Action<object,AnnouncementEventArgs> (OnlineAnnouncementReceived ?? delegate {});
				return online.BeginInvoke (this, new AnnouncementEventArgs (endpointDiscoveryMetadata, messageSequence), callback, state);
			default:
				if (OnlineAnnouncementReceived != null)
					OnlineAnnouncementReceived (this, new AnnouncementEventArgs (endpointDiscoveryMetadata, messageSequence));
				var result = new TempAsyncResult (null, state);
				if (callback != null)
					callback (result);
				return result;
			}
		}
Exemplo n.º 23
0
        //-----------------------------------------------------
        //  Offline Announcements
        //-----------------------------------------------------

        #region OfflineAnnouncement

        /// <summary>
        /// Handles Offline announcements.
        /// </summary>
        /// <param name="messageSequence">The discovery message sequence.</param>
        /// <param name="endpointDiscoveryMetadata">The endpoint discovery metadata.</param>
        override protected void OnOfflineAnnouncement(DiscoveryMessageSequence messageSequence,
                                                      EndpointDiscoveryMetadata endpointDiscoveryMetadata)
        {
            if (!_dictionary.ContainsKey(endpointDiscoveryMetadata.Address))
            {
                return;
            }

            IProducerConsumerCollection <EndpointDiscoveryMetadata> items = _dictionary[endpointDiscoveryMetadata.Address]
                                                                            as IProducerConsumerCollection <EndpointDiscoveryMetadata>;

            items.TryTake(out endpointDiscoveryMetadata);

            if (0 == items.Count)
            {
                IEnumerable <EndpointDiscoveryMetadata> value;

                _dictionary.TryRemove(endpointDiscoveryMetadata.Address, out value);
            }
        }
        /// <summary>
        /// Override this method to handle an offline 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 OnBeginOfflineAnnouncement(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.Remove(endpointDiscoveryMetadata);
                    Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Discovery proxy endpoint offline : {0} - {1}", endpointDiscoveryMetadata.GetSpecifiedName(), endpointDiscoveryMetadata.Address.Uri));
                }
            }

            return(new CompletedAsyncResult(callback, state));
        }
Exemplo n.º 25
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);
        }
Exemplo n.º 26
0
        //-----------------------------------------------------
        //  Offline Announcements
        //-----------------------------------------------------

        #region OfflineAnnouncement

        /// <summary>
        /// Handles Offline announcements.
        /// </summary>
        /// <param name="messageSequence">The discovery message sequence.</param>
        /// <param name="endpointDiscoveryMetadata">The endpoint discovery metadata.</param>
        override protected void OnOfflineAnnouncement(DiscoveryMessageSequence messageSequence,
                                                      EndpointDiscoveryMetadata endpointDiscoveryMetadata)
        {
            Parallel.ForEach(endpointDiscoveryMetadata.ContractTypeNames, (name) =>
            {
                if (!_dictionary.ContainsKey(name))
                {
                    return;
                }

                IProducerConsumerCollection <EndpointDiscoveryMetadata> items = _dictionary[name]
                                                                                as IProducerConsumerCollection <EndpointDiscoveryMetadata>;

                items.TryTake(out endpointDiscoveryMetadata);

                if (0 == items.Count)
                {
                    IEnumerable <EndpointDiscoveryMetadata> value;

                    _dictionary.TryRemove(name, out value);
                }
            });
        }
Exemplo n.º 27
0
		public static DiscoveryMessageSequence11 FromDiscoveryMessageSequence (DiscoveryMessageSequence discoveryMessageSequence)
		{
			throw new NotImplementedException ();
		}
Exemplo n.º 28
0
 internal void AddDiscoveredEndpoint(EndpointDiscoveryMetadata endpointDiscoveryMetadata,
     DiscoveryMessageSequence messageSequence)
 {
     this.messageSequenceTable.Add(endpointDiscoveryMetadata, messageSequence);
     this.endpoints.Add(endpointDiscoveryMetadata);
 }
Exemplo n.º 29
0
 protected override IAsyncResult OnBeginOnlineAnnouncement(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, object state)
 {
     this.AddOnlineService(endpointDiscoveryMetadata);
     return(new OnOnlineAnnouncementAsyncResult(callback, state));
 }
Exemplo n.º 30
0
 /// <summary>
 /// OnBeginOnlineAnnouncement method is called when a Hello message is received by the Proxy
 /// </summary>
 /// <param name="messageSequence">The discovery message sequence.</param>
 /// <param name="metadata">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 metadata, AsyncCallback callback, object state)
 {
     _logger.Info("Received HELLO from {0}", metadata.Address);
     AddOnlineService(metadata);
     return(new OnOnlineAnnouncementAsyncResult(callback, state));
 }
 DiscoveryMessageSequence11(DiscoveryMessageSequence discoveryMessageSequence)
 {
     this.discoveryMessageSequence = discoveryMessageSequence;
 }
 DiscoveryMessageSequence11()
 {
     this.discoveryMessageSequence = new DiscoveryMessageSequence();
 }
 DiscoveryMessageSequenceApril2005()
 {
     this.discoveryMessageSequence = new DiscoveryMessageSequence();
 }
		public void ReadXml (XmlReader reader)
		{
			source = DiscoveryMessageSequence.ReadXml (reader, version);
		}
 internal DiscoveryMessageSequenceApril2005(DiscoveryMessageSequence source)
 {
     this.source = source;
 }
 protected override ProbeMatchesMessage11 GetProbeResponse(
     DiscoveryMessageSequence discoveryMessageSequence,
     Collection <EndpointDiscoveryMetadata> matchingEndpoints)
 {
     return(ProbeMatchesMessage11.Create(discoveryMessageSequence, matchingEndpoints));
 }
Exemplo n.º 37
0
 //Online
 protected override IAsyncResult OnBeginOnlineAnnouncement(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, object state)
 {
     this.Endpoints[endpointDiscoveryMetadata.Address] = endpointDiscoveryMetadata;
     return(new DiscoveryAsyncResult(callback, state));
 }
Exemplo n.º 38
0
 public static DiscoveryMessageSequenceCD1 FromDiscoveryMessageSequence(DiscoveryMessageSequence discoveryMessageSequence)
 {
     return(new DiscoveryMessageSequenceCD1(discoveryMessageSequence));
 }
Exemplo n.º 39
0
 internal DiscoveryMessageSequenceCD1(DiscoveryMessageSequence source)
 {
     this.source = source;
 }
 DiscoveryMessageSequence11(DiscoveryMessageSequence discoveryMessageSequence)
 {
     this.discoveryMessageSequence = discoveryMessageSequence;
 }
 DiscoveryMessageSequenceApril2005(DiscoveryMessageSequence discoveryMessageSequence)
 {
     this.discoveryMessageSequence = discoveryMessageSequence;
 }
 DiscoveryMessageSequence11()
 {
     this.discoveryMessageSequence = new DiscoveryMessageSequence();
 }
 protected override ResolveMatchesMessage11 GetResolveResponse(
     DiscoveryMessageSequence discoveryMessageSequence,
     EndpointDiscoveryMetadata matchingEndpoint)
 {
     return(ResolveMatchesMessage11.Create(discoveryMessageSequence, matchingEndpoint));
 }
Exemplo n.º 44
0
		internal ResolveResponse (EndpointDiscoveryMetadata metadata, DiscoveryMessageSequence sequence)
		{
			EndpointDiscoveryMetadata = metadata;
			MessageSequence = sequence;
		}
		public static DiscoveryMessageSequenceApril2005 FromDiscoveryMessageSequence (DiscoveryMessageSequence discoveryMessageSequence)
		{
			return new DiscoveryMessageSequenceApril2005 (discoveryMessageSequence);
		}
Exemplo n.º 46
0
 // OnBeginOnlineAnnouncement method is called when a Hello message is received by the Proxy
 protected override IAsyncResult OnBeginOnlineAnnouncement(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, object state)
 {
     this.AddOnlineService(endpointDiscoveryMetadata);
     return new OnOnlineAnnouncementAsyncResult(callback, state);
 }
		internal DiscoveryMessageSequenceApril2005 (DiscoveryMessageSequence source)
		{
			this.source = source;
		}
Exemplo n.º 48
0
 public void ReadXml(XmlReader reader)
 {
     source = DiscoveryMessageSequence.ReadXml(reader, version);
 }
 public static DiscoveryMessageSequenceApril2005 FromDiscoveryMessageSequence(DiscoveryMessageSequence discoveryMessageSequence)
 {
     return(new DiscoveryMessageSequenceApril2005(discoveryMessageSequence));
 }