// Unregister address for a node from the resolver service public override void Unregister(object registrationId, TimeSpan timeout) { ChannelFactory <ICustomPeerResolverChannel> factory = new ChannelFactory <ICustomPeerResolverChannel>(config); ICustomPeerResolverChannel client = factory.CreateChannel(); client.Unregister((int)registrationId); client.Close(); factory.Close(); }
// Updates a node's registration with the resolver service. public override void Update(object registrationId, PeerNodeAddress updatedNodeAddress, TimeSpan timeout) { ChannelFactory <ICustomPeerResolverChannel> factory = new ChannelFactory <ICustomPeerResolverChannel>(config); ICustomPeerResolverChannel client = factory.CreateChannel(); MaskScopeId(updatedNodeAddress.IPAddresses); client.Update((int)registrationId, updatedNodeAddress); client.Close(); factory.Close(); }
// Register address for a node participating in a mesh identified by meshId with the resolver service public override object Register(string meshId, PeerNodeAddress nodeAddress, TimeSpan timeout) { ChannelFactory <ICustomPeerResolverChannel> factory = new ChannelFactory <ICustomPeerResolverChannel>(config); ICustomPeerResolverChannel client = factory.CreateChannel(); MaskScopeId(nodeAddress.IPAddresses); int registrationId = client.Register(meshId, nodeAddress); client.Close(); factory.Close(); return(registrationId); }
// Query the resolver service for addresses associated with a mesh ID public override ReadOnlyCollection <PeerNodeAddress> Resolve(string meshId, int maxAddresses, TimeSpan timeout) { PeerNodeAddress[] addresses = null; ChannelFactory <ICustomPeerResolverChannel> factory = new ChannelFactory <ICustomPeerResolverChannel>(config); ICustomPeerResolverChannel client = factory.CreateChannel(); addresses = client.Resolve(meshId, maxAddresses); client.Close(); factory.Close(); // If addresses couldn't be obtained, return empty collection if (addresses == null) { addresses = new PeerNodeAddress[0]; } return(new ReadOnlyCollection <PeerNodeAddress>(addresses)); }