次の方法で共有


Extending the CustomPeerResolverService: LinearResolverService.cs

For background information on PeerChannel discovery mechanisms and options please refer to https://msdn2.microsoft.com/en-us/library/aa702771.aspx.

By default, PeerChannel uses the Windows Peer Name Resolution Protocol (PNRP) for discovery of peers and neighbors in the mesh. But we also provide an alternative server-based out-of-the-box discovery service- the CustomPeerResolverService- for situations/platforms where PNRP is not available or feasible. This post talks about how to go about extending default implementation of the custom resolver, for greater control over mesh shaping and discovery.

In general, when a Peer node first starts up, it tries to look up new neighbors by invoking the CustomPeerResolverService.Resolve() method before going ahead and registering itself with the resolver service. To control the shape of your mesh, for example, all you would need is an extension to the resolver service which is similar to default implementation, except for custom Resolve(), Register(), Unregister() methods. In actual programming terms, it means that your customResolverSerivce class implementation would simply inherit from our base implementation and then have scenario-specific customizations and overrides.

Sample User Scenario: I want to create a linear mesh (i.e. every node is connected to exactly one neighbor; the custom name resolver should therefore provide the new requesting node with referrals to only the last node to register with it).

Solution: Attached to the post is a simple extension to the default CustomPeerResolverService with overridden Resolve(), Register(), Unregister() methods.

Configuring your PeerChannel client application to use your custom service: This can be done by configuring the instance of NetPeerTcpBinding in your application like so: 

<snip>

NetPeerTcpBinding binding = new NetPeerTcpBinding();

customResolverEpr =

"net.tcp://" + customResolverHostName + ":" + CustomResolverServicePort.ToString() + "/DefaultResolverService";

binding.Resolver.Mode =

PeerResolverMode.Custom;

binding.Resolver.Custom.Address =

new EndpointAddress(customResolverEpr);

binding.Resolver.Custom.Binding =

new NetTcpBinding(SecurityMode.None);

</snip>

LinearResolverService.cs

Comments

  • Anonymous
    June 22, 2007
    The comment has been removed

  • Anonymous
    June 22, 2007
    No, we dont call Register(), but Refresh() which is called with a clientID parameter.

  • Anonymous
    August 19, 2007
    Hello, Using above linear mesh means a registered node is only aware of immediate neighbor? If it does, does each node just message his neighbour, or the whole mesh? Thanks in advance. Regards, Mark

  • Anonymous
    August 21, 2007
    Hi Mark, Even though the mesh is shaped such that every node is aware of just one other neighbor, when it sends a message however, it gets propagated to the entire mesh. Thanks, Shalini

  • Anonymous
    February 07, 2014
    Hi, Mark. How to do a client register on host of customResolverService?