/// <summary> /// Sends ProbeMatch message. /// </summary> /// <param name="relatesTo"> "relatesTo" field in soap header.</param> /// <param name="instanceId">instanceId field in soap identifier for the current /// instance of the device being published</param> /// <param name="messageNumber">The message number</param> /// <param name="matches">The service property matches</param> /// <param name="ip">The remote ip address</param> /// <param name="port">The used port number for transporting</param> public void SendProbeMatchMessage( string relatesTo, string instanceId, uint messageNumber, ServiceProperty[] matches, string ip, int port) { CustomProbeMatchType[] probeMatches = new CustomProbeMatchType[matches.Length]; for (int i = 0; i < matches.Length; i++) { CustomProbeMatchType match = new CustomProbeMatchType(); match.EndpointReference = new EndpointReferenceType(); match.EndpointReference.Address = new AttributedURI(); match.EndpointReference.Address.Value = matches[i].Address; match.MetadataVersion = matches[i].MetadataVersion; match.Scopes = new ScopesType(new string[] { matches[i].Scopes }); match.Types = matches[i].Types; match.XAddrs = matches[i].XAddrs; match.PeerDistData = new PeerDistData(matches[i].BlockCount); probeMatches[i] = match; } this.server.SendUnicast( this.server.CreateProbeMatchMessage(relatesTo, instanceId, messageNumber, probeMatches), ip, port); }
/// <summary> /// Create Probematch message /// </summary> /// <param name="relatesTo">The probe message relates to</param> /// <param name="instanceId">The instanceId of the probe message</param> /// <param name="messageNumber">The messageNumber of probe message</param> /// <param name="matches">The probe matches</param> /// <returns>return probeMatch message</returns> public SoapEnvelope CreateProbeMatchMessage( string relatesTo, string instanceId, uint messageNumber, CustomProbeMatchType[] matches) { ProbeMatchType[] wsdiscoveryMatches = new ProbeMatchType[matches.Length]; XmlDocument doc = new XmlDocument(); for (int i = 0; i < matches.Length; i++) { wsdiscoveryMatches[i] = new ProbeMatchType(); wsdiscoveryMatches[i].EndpointReference = matches[i].EndpointReference; wsdiscoveryMatches[i].MetadataVersion = matches[i].MetadataVersion; wsdiscoveryMatches[i].Scopes = matches[i].Scopes; wsdiscoveryMatches[i].Types = matches[i].Types; wsdiscoveryMatches[i].XAddrs = matches[i].XAddrs; XmlElement peerDist = doc.CreateElement( "PeerDist", "PeerDistData", "http://schemas.microsoft.com/p2p/2007/09/PeerDistributionDiscovery"); XmlElement blockCount = doc.CreateElement( "PeerDist", "BlockCount", "http://schemas.microsoft.com/p2p/2007/09/PeerDistributionDiscovery"); blockCount.InnerText = matches[i].PeerDistData.BlockCount; peerDist.AppendChild(blockCount); wsdiscoveryMatches[i].Any = new XmlElement[] { peerDist }; } return this.service.CreateProbeMatchMessage(relatesTo, instanceId, messageNumber, wsdiscoveryMatches); }