开发者

When P2P Won't Connect, How to "Restart" it in the Client

I have implemented a wcf P2P setup in a simple application.

My question is the result of testing this with multiple clients. Nine times out of ten, all the clients will synch up in the mesh and connect without issue.

However, depending on which client I close and then re-open, it will not reconnect to the mesh. The other clients do not see it.

My question is how can I perhaps close and re-open the p2p on this client so it can attempt to connect again? I'd set a timer perhaps that every minute or so if it isn't connected, it might assume there is 开发者_如何学Can issue so it would close it's p2p endpoint or whatever and then re-open it to refresh the whole thing.

I ask this since if I close this client, then re-open it, it will reconnect to the mesh.

I want fool-proof connections. Such as, you open a client and the client will figure out if it has to restart or it isn't getting connection after a certain amount of time so it attempts to "flush" the connection and rebuild it.

Does this make sense?


It's going to be difficult to determine that you're not connected to the mesh because of some unknown fault condition rather than simply being alone.

The IOnlineStatus property on the peer channel can tell you if you're alone in the mesh (false), or if you have connected peers (true). You can get this property by registering for the status change event like so:

IOnlineStatus status = myPeerChannel.GetProperty<IOnlineStatus>();
status.Online += new EventHandler(MyOnlineEventHandler);
status.Offline += new EventHandler(MyOfflineEventHandler);

So I suppose one way to do this would be to have a timer that checks your online status and if you go more than X amount of time being offline, dispose of your channel and create a new one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜