I am using WCF in .NET 3.5 to implement a peer to peer networking application. To resolve peer nodes I am using PNRP.
IGlobalStoreServiceContract is my contract as shown below,
[ServiceContract(Namespace = "http://GlobalStoreEventDriven.API", CallbackContract = typeof(IGlobalStoreServiceContract))]
internal interface IGlobalStoreServiceContract
{
[OperationContract(IsOneWay = true)]
void NotifyGlobalStoreDataInserted(string globalGroup, DateTime maxDateTime);
[OperationContract(IsOneWay = true)]
void RegisterNode();
[OperationContract(IsOneWay = true)]
void SynchronizeMemberList(Guid clientId);
}
I am using some code like this to join each node to the peer to peer network.
DuplexChannelFactory<IGlobalStoreChannel> channelFactory = new DuplexChannelFactory<IGlobalStoreChannel>(instance, "GlobalStoreAPIEndPoint");
IGlobalStoreChannel globalStoreChannel = channelFactory.CreateChannel();
globalStoreChannel.Open();
My question is as soon as I have opened the channel how can I best tell if other peer nodes are on the network?
For instance I could call one of the methods in my contract RegisterNode, and each node in the network could use a callback to call SynchronizeMemberList. I would then know whether other nodes were there.
The trouble with that is it is all asynchronous. If I call RegisterNode and no one replies, it doesn't really mean no one is there, it could just mean that I didn't wait long enough.
What do you reckon? Any suggestions?