public static HelloMessageApril2005 Create(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata) { return new HelloMessageApril2005() { MessageSequence = DiscoveryMessageSequenceApril2005.FromDiscoveryMessageSequence(messageSequence), Hello = EndpointDiscoveryMetadataApril2005.FromEndpointDiscoveryMetadata(endpointDiscoveryMetadata) }; }
public static ByeMessage11 Create(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata) { return new ByeMessage11() { MessageSequence = DiscoveryMessageSequence11.FromDiscoveryMessageSequence(messageSequence), Bye = EndpointDiscoveryMetadata11.FromEndpointDiscoveryMetadata(endpointDiscoveryMetadata) }; }
public static HelloMessageCD1 Create(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata) { return new HelloMessageCD1() { MessageSequence = DiscoveryMessageSequenceCD1.FromDiscoveryMessageSequence(messageSequence), Hello = EndpointDiscoveryMetadataCD1.FromEndpointDiscoveryMetadata(endpointDiscoveryMetadata) }; }
public static ResolveMatchesMessage11 Create(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata) { return new ResolveMatchesMessage11() { MessageSequence = DiscoveryMessageSequence11.FromDiscoveryMessageSequence(messageSequence), ResolveMatches = ResolveMatches11.Create(endpointDiscoveryMetadata) }; }
internal static ByeMessageApril2005 Create(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata) { return new ByeMessageApril2005() { MessageSequence = DiscoveryMessageSequenceApril2005.FromDiscoveryMessageSequence(messageSequence), Bye = EndpointDiscoveryMetadataApril2005.FromEndpointDiscoveryMetadata(endpointDiscoveryMetadata) }; }
public static ProbeMatchesMessageApril2005 Create(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata) { return new ProbeMatchesMessageApril2005() { MessageSequence = DiscoveryMessageSequenceApril2005.FromDiscoveryMessageSequence(messageSequence), ProbeMatches = ProbeMatchesApril2005.Create(endpointDiscoveryMetadata) }; }
public static ProbeMatchesMessageCD1 Create(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata) { return new ProbeMatchesMessageCD1() { MessageSequence = DiscoveryMessageSequenceCD1.FromDiscoveryMessageSequence(messageSequence), ProbeMatches = ProbeMatchesCD1.Create(endpointDiscoveryMetadata) }; }
public static EndpointDiscoveryMetadata11 FromEndpointDiscoveryMetadata(EndpointDiscoveryMetadata endpointDiscoveryMetadata) { if (endpointDiscoveryMetadata == null) { throw FxTrace.Exception.ArgumentNull("endpointDiscoveryMetadata"); } return new EndpointDiscoveryMetadata11(endpointDiscoveryMetadata); }
public static ResolveMatches11 Create(EndpointDiscoveryMetadata endpointDiscoveryMetadata) { ResolveMatches11 resolveMatches = new ResolveMatches11(); if (endpointDiscoveryMetadata != null) { resolveMatches.ResolveMatch = EndpointDiscoveryMetadata11.FromEndpointDiscoveryMetadata(endpointDiscoveryMetadata); } return resolveMatches; }
public static ResolveMatchesApril2005 Create(EndpointDiscoveryMetadata endpointDiscoveryMetadata) { ResolveMatchesApril2005 resolveMatches = new ResolveMatchesApril2005(); if (endpointDiscoveryMetadata != null) { resolveMatches.ResolveMatch = EndpointDiscoveryMetadataApril2005.FromEndpointDiscoveryMetadata(endpointDiscoveryMetadata); } return resolveMatches; }
private EndpointDiscoveryMetadata[] CreateEndpoints(int count) { return(Enumerable.Range(1, count).Select(i => { var endpoint = new EndpointDiscoveryMetadata { ContractTypeNames = { contract }, Address = new EndpointAddress("http://localhost/endpoint" + i) }; firstAvailable.RegisterTarget(endpoint); return endpoint; }).ToArray()); }
public void CanCreatePolicyFactory() { var roundRobinFactory = new ContractLoadBalancePolicyFactory <RoundRobinPolicy>(); var endpoint = new EndpointDiscoveryMetadata { ContractTypeNames = { new XmlQualifiedName("foo") } }; var policies = roundRobinFactory.CreatePolicies(endpoint); Assert.AreEqual(1, policies.Length); Assert.IsInstanceOf <RoundRobinPolicy>(policies[0]); Assert.IsNull(policies[0].ChooseTarget()); }
public void CanCreatePolicyFactory() { var roundRobinFactory = new ScopeLoadBalancePolicyFactory <RoundRobinPolicy>(); var endpoint = new EndpointDiscoveryMetadata { Scopes = { new Uri("urn:scope:foo") } }; var policies = roundRobinFactory.CreatePolicies(endpoint); Assert.AreEqual(1, policies.Length); Assert.IsInstanceOf <RoundRobinPolicy>(policies[0]); Assert.IsNull(policies[0].ChooseTarget()); }
private static void OnOfflineAnnouncement(object sender, AnnouncementEventArgs e) { EndpointDiscoveryMetadata metadata = e.EndpointDiscoveryMetadata; if (metadata.ListenUris.Count > 0 && metadata.ListenUris[0].Equals(endpointAddress.Uri)) { Console.WriteLine("Service said goodbye!!"); endpointAddress = null; accelerationServiceEndPoint = null; deviceInfoServiceEndPoint = null; dataLoggingServiceEndPoint = null; } }
private void HandleOnlineAnnouncementReceived(EndpointDiscoveryMetadata metadata) { // Only acknowledge service contracts that we actually know about. if (metadata.ContractTypeNames.FirstOrDefault(x => x.Name == typeof(IBootstrapEndpoint).Name) != null) { var id = GetEndpointId(metadata); var address = metadata.Address.Uri; // Note that the EndpointId meta data is defined by the BootstrapChannel // Do we want to thread this? LocatedRemoteEndpointOnChannel(id, address); } }
public void WillRejectEndpointsNotSupportingContract() { var roundRobinFactory = new ContractLoadBalancePolicyFactory <RoundRobinPolicy>(); var endpoint = new EndpointDiscoveryMetadata { ContractTypeNames = { new XmlQualifiedName("foo") } }; var policies = roundRobinFactory.CreatePolicies(endpoint); Assert.IsFalse(policies[0].RegisterTarget(new EndpointDiscoveryMetadata { ContractTypeNames = { new XmlQualifiedName("bar") } })); }
public void WillRejectEndpointsNotSupportingScope() { var roundRobinFactory = new ScopeLoadBalancePolicyFactory <RoundRobinPolicy>(); var endpoint = new EndpointDiscoveryMetadata { Scopes = { new Uri("urn:scope:foo") } }; var policies = roundRobinFactory.CreatePolicies(endpoint); Assert.IsFalse(policies[0].RegisterTarget(new EndpointDiscoveryMetadata { Scopes = { new Uri("urn:scope:bar") } })); }
private void Init(GameMasterSvc gameSession, string clientId, EndpointDiscoveryMetadata playerMetadata) { Console.WriteLine("Player " + "(" + clientId + ") has logged in"); Console.WriteLine(); this.ClientId = clientId; this.GameSession = gameSession; this.RemoteMetadata = playerMetadata; this.Client = null; this.DisplayName = null; this.CurrentMatch = null; this.Locker.Release(); }
protected override IAsyncResult BeginSendProxyAnnouncement( IDiscoveryResponseContractApril2005 responseChannel, DiscoveryMessageSequence discoveryMessageSequence, EndpointDiscoveryMetadata proxyEndpointDiscoveryMetadata, AsyncCallback callback, object state) { return(responseChannel.BeginHelloOperation( HelloMessageApril2005.Create( discoveryMessageSequence, proxyEndpointDiscoveryMetadata), callback, state)); }
public void AnnonceOnlineOfflineAddressSchemeMismatch2() { var ac = new AnnouncementClient(new AnnouncementEndpoint() { Binding = new BasicHttpBinding(), Address = new EndpointAddress("soap.udp://localhost:37564") }); var edm = new EndpointDiscoveryMetadata(); try { ac.AnnounceOnline(edm); } finally { ac.Close(); } }
protected override IAsyncResult BeginSendFindResponse( IDiscoveryResponseContractApril2005 responseChannel, DiscoveryMessageSequence discoveryMessageSequence, EndpointDiscoveryMetadata matchingEndpoint, AsyncCallback callback, object state) { return(responseChannel.BeginProbeMatchOperation( ProbeMatchesMessageApril2005.Create( discoveryMessageSequence, matchingEndpoint), callback, state)); }
public void AnnonceOnlineOfflineNoEndpointAddress() { var ac = new AnnouncementClient(new AnnouncementEndpoint() { Binding = new BasicHttpBinding() }); var edm = new EndpointDiscoveryMetadata(); try { ac.AnnounceOnline(edm); } finally { ac.Close(); } }
/// <summary> /// Unregisters the online service. /// </summary> /// <param name="metadata">The endpoint discovery metadata.</param> public void UnregisterDiscoMetadata(EndpointDiscoveryMetadata metadata) { //var uri = new Uri(metadata.Address.ToString()); //if (uri.Scheme == Uri.UriSchemeNetPipe) //{ // var newUrl = metadata.Address.ToString().Replace(uri.Host,"localhost"); // metadata.Address = new EndpointAddress(newUrl); //} if (EngineConfiguration.LogRegistration) { Logger.Info("Unregistering metadata : {0}", metadata.Address); } _onlineServices.Remove(metadata.Address); }
// looks like EndpointAddress is *ignored* public void AnnonceOnlineOfflineAddressSchemeMismatch() { var ac = new AnnouncementClient(new UdpAnnouncementEndpoint() { Address = new EndpointAddress("http://localhost:37564") }); var edm = new EndpointDiscoveryMetadata(); try { ac.AnnounceOnline(edm); ac.AnnounceOffline(edm); } finally { ac.Close(); } }
private String[] GetAllowedClients(EndpointDiscoveryMetadata EndPoint) { String AllowedClients = null; foreach (XElement item in EndPoint.Extensions) { try { AllowedClients = item.Element(CommuncationInfo.MetaDataIPAddresses).Value; break; } catch { continue; } } return(AllowedClients.ToUpper().Split(new String[] { ";" }, StringSplitOptions.RemoveEmptyEntries)); }
static void PrintEndpointDiscoveryMetadata(EndpointDiscoveryMetadata endpointDiscoveryMetadata) { foreach (XmlQualifiedName contractTypeName in endpointDiscoveryMetadata.ContractTypeNames) { Console.WriteLine("\tContractTypeName: {0}", contractTypeName); } foreach (Uri scope in endpointDiscoveryMetadata.Scopes) { Console.WriteLine("\tScope: {0}", scope); } foreach (Uri listenUri in endpointDiscoveryMetadata.ListenUris) { Console.WriteLine("\tListenUri: {0}", listenUri); } }
protected override IAsyncResult OnBeginResolve(ResolveCriteria resolveCriteria, AsyncCallback callback, object state) { EndpointDiscoveryMetadata matchingEndpoint = null; foreach (EndpointDiscoveryMetadata endpointDiscoveryMetadata in this.publishedEndpoints) { if (resolveCriteria.Address == endpointDiscoveryMetadata.Address) { matchingEndpoint = endpointDiscoveryMetadata; break; } } return(new ResolveAsyncResult(matchingEndpoint, callback, state)); }
public virtual bool RemoveEndpoint(EndpointDiscoveryMetadata endpoint) { var removed = false; using (var locker = @lock.ForReadingUpgradeable()) { policies.ForEach(policy => removed = removed | policy.RemoveTarget(endpoint)); if (removed) { locker.Upgrade(); endpoints.Remove(endpoint.Address); } } return(removed); }
void ResolveCompleted(object sender, ResolveCompletedEventArgs e) { if (e.Error != null) { throw e.Error; } try { this.endpointDiscoveryMetadata = e.Result.EndpointDiscoveryMetadata; } catch (Exception exception) { this.Complete(false, exception); } }
/// <summary> /// Prints the discovery metadata. /// </summary> /// <param name="metadata">The endpoint discovery metadata.</param> /// <param name="verb">The verb.</param> /// <param name="newCount">The new count.</param> void PrintDiscoveryMetadata(EndpointDiscoveryMetadata metadata, string verb) { lock (_sync) { foreach (var contractName in metadata.ContractTypeNames) { var firstContractName = contractName.ToString(); if (firstContractName.Contains("/mex:")) { continue; } _logger.Info("{0} [{1}] @ {2}", verb.ToUpper(), firstContractName, metadata.Address); break; } } }
EndpointDiscoveryMetadata MatchFromOnlineService(ResolveCriteria criteria) { EndpointDiscoveryMetadata matchingEndpoint = null; lock (this.onlineServices) { foreach (EndpointDiscoveryMetadata endpointDiscoveryMetadata in this.onlineServices.Values) { if (criteria.Address == endpointDiscoveryMetadata.Address) { matchingEndpoint = endpointDiscoveryMetadata; } } } return(matchingEndpoint); }
private void OnOfflineAnnouncement(object sender, AnnouncementEventArgs e) { EndpointDiscoveryMetadata metadata = e.EndpointDiscoveryMetadata; FindCriteria criteria = new FindCriteria(typeof(T)); if (criteria.IsMatch(metadata)) { // 指定类型的服务下线 if (cache.Contains(metadata.Address.Uri)) { cache.Remove(metadata); Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Announcement endpoint offline : {0} - {1}", metadata.GetSpecifiedName(), metadata.Address.Uri)); } } }
private static void DiscoveryClient_FindCompleted(object sender, FindCompletedEventArgs e) { Console.WriteLine("Find finished"); if (e.Result.Endpoints.Count > 0) { discoveredService = e.Result.Endpoints[0]; CallService(); } else { Console.WriteLine("Service not found"); } Console.WriteLine("Now the client really finished"); Console.ReadLine(); }
public void AnnonceOnlineOfflineHttpMessageVersionMismatch() { var ac = new AnnouncementClient(new AnnouncementEndpoint() { Binding = new BasicHttpBinding() { SendTimeout = TimeSpan.FromSeconds(10), ReceiveTimeout = TimeSpan.FromSeconds(10) }, Address = http_address }); var edm = new EndpointDiscoveryMetadata(); try { ac.AnnounceOnline(edm); } finally { ac.Close(); } }
/// <summary> /// 获取终结点发现元数据扩展的特定名称 /// </summary> /// <param name="metadata">终结点发现元数据</param> /// <returns>扩展的特定名称</returns> public static string GetSpecifiedName(this EndpointDiscoveryMetadata metadata) { if (metadata == null) { throw new ArgumentNullException("metadata"); } XElement nameElement = metadata.Extensions.Elements("SpecifiedName").FirstOrDefault(); string name = null; if (nameElement != null) { name = nameElement.Value; } return(name); }
void MatchFromOnlineService(FindRequestContext findRequestContext) { lock (this._onlineServices) { string foundId = findRequestContext.Criteria.Extensions.FirstOrDefault(x => x.Name.LocalName == "Id")?.Value; if (foundId != null) { EndpointDiscoveryMetadata endpointMetadata = this._onlineServices[foundId]; if (!findRequestContext.Criteria.IsMatch(endpointMetadata)) { return; } findRequestContext.AddMatchingEndpoint(endpointMetadata); } else { foreach (EndpointDiscoveryMetadata endpointMetadata in this._onlineServices.Values) { if (!findRequestContext.Criteria.IsMatch(endpointMetadata)) { continue; } int countdown = findRequestContext.Criteria.Extensions.Count; foreach (XElement elem in findRequestContext.Criteria.Extensions) { if (endpointMetadata.Extensions.All(x => x.Name.LocalName == elem.Name.LocalName && x.Value != elem.Value)) { break; } countdown--; } if (countdown == 0) { findRequestContext.AddMatchingEndpoint(endpointMetadata); } } } } }
public void AnnonceOnlineOfflineHttpWSA10() { var binding = new CustomBinding(new HttpTransportBindingElement()) { SendTimeout = TimeSpan.FromSeconds(10), ReceiveTimeout = TimeSpan.FromSeconds(10) }; var ac = new AnnouncementClient(new AnnouncementEndpoint() { Binding = binding, Address = http_address }); var edm = new EndpointDiscoveryMetadata(); try { ac.AnnounceOnline(edm); } finally { ac.Close(); } }
private static void OnOnlineAnnouncement(object sender, AnnouncementEventArgs e) { EndpointDiscoveryMetadata metadata = e.EndpointDiscoveryMetadata; // Check if service is SSimpDeviceType which is the Host service used foreach (System.Xml.XmlQualifiedName type in metadata.ContractTypeNames) { if (type.Equals(new System.Xml.XmlQualifiedName("AccelerationDeviceType", "http://www.teco.edu/AccelerationService"))) { Console.WriteLine("New service found: !!"); AnnouncementFound = true; endpointAddress = new EndpointAddress(metadata.ListenUris[0]); GetServiceEndPoints(endpointAddress); Console.WriteLine("Service can now be invoked"); } } }
private static void OnOfflineAnnouncement(object sender, AnnouncementEventArgs e) { Console.WriteLine("Bye!"); EndpointDiscoveryMetadata metadata = e.EndpointDiscoveryMetadata; if (metadata != null && metadata.ListenUris.Count > 0) { foreach (edu.teco.DPWS.Device device in knownDevices) { if (device.EndpointAddress.Uri.Equals(metadata.ListenUris[0])) { knownDevices.Remove(device); Console.WriteLine("Device removed {0}:{1} at {2}", device.GetDeviceType().Namespace, device.GetDeviceType().Name, metadata.ListenUris[0]); break; } } } }
public void WillFallBackToContractPolicyWhenNoScopes() { var roundRobinFactory = new ScopeLoadBalancePolicyFactory <RoundRobinPolicy>(); var endpoint = new EndpointDiscoveryMetadata { ContractTypeNames = { new XmlQualifiedName("foo") } }; var policies = roundRobinFactory.CreatePolicies(endpoint); Assert.IsTrue(policies[0].RegisterTarget(new EndpointDiscoveryMetadata { ContractTypeNames = { new XmlQualifiedName("foo") } })); Assert.IsFalse(policies[0].RegisterTarget(new EndpointDiscoveryMetadata { ContractTypeNames = { new XmlQualifiedName("bar") } })); }
public void ReadXml (XmlReader reader) { source = EndpointDiscoveryMetadata.ReadXml (reader, version); }
public static EndpointDiscoveryMetadata11 FromEndpointDiscoveryMetadata (EndpointDiscoveryMetadata endpointDiscoveryMetadata) { throw new NotImplementedException (); }
public static EndpointDiscoveryMetadata11 FromEndpointDiscoveryMetadata (EndpointDiscoveryMetadata endpointDiscoveryMetadata) { return new EndpointDiscoveryMetadata11 (endpointDiscoveryMetadata); }
internal EndpointDiscoveryMetadata11 (EndpointDiscoveryMetadata source) { this.source = source; }
public static EndpointDiscoveryMetadataApril2005 FromEndpointDiscoveryMetadata (EndpointDiscoveryMetadata endpointDiscoveryMetadata) { return new EndpointDiscoveryMetadataApril2005 (endpointDiscoveryMetadata); }
EndpointDiscoveryMetadata11() { endpointDiscoveryMetadata = new EndpointDiscoveryMetadata(); }
internal EndpointDiscoveryMetadataApril2005 (EndpointDiscoveryMetadata source) { this.source = source; }
EndpointDiscoveryMetadata11(EndpointDiscoveryMetadata endpointDiscoveryMetadata) { this.endpointDiscoveryMetadata = endpointDiscoveryMetadata; }
EndpointDiscoveryMetadataApril2005(EndpointDiscoveryMetadata endpointDiscoveryMetadata) { this.endpointDiscoveryMetadata = endpointDiscoveryMetadata; }
EndpointDiscoveryMetadataApril2005() { this.endpointDiscoveryMetadata = new EndpointDiscoveryMetadata(); }