views:

427

answers:

2

How can I enumerate some sort of location identifier for all of the connected clients for a servicehost? I'm using a duplex connection for long running calculations. The Service host is a singleton.

I can figure out (in .net 3.5) the ip of the calling client but i am unsure how to get the ip of all connected clients.

+1  A: 

I don't think there's anything built-in for that, but it'd be pretty easy to build a tracking IServiceBehavior + IDispatchMessageInspector that would inspect the RemoteClientEnpointMessageProperty before the call is dispatched to the service impl and stick the client IP into a shared list, and remove it when the call/session ends.

nitzmahone
+1  A: 

By default, WCF promotes the use of "per-call" services, e.g. your client calls, the request gets handled, and then the client is disconnected again right away.

WCF doesn't lend itself too well for and isn't intended for long-running connections - so you can't really "enumerate the currently connected users" since there aren't any (or only for a fraction of a second).

WCF is not like a Windows domain server where you log in and stay logged in for an extended period of time.

marc_s
Sorry I wasn't clear in my post but I'm not using the default service behavior.[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]With InstanceContexMode.Single there is one instance with a longer lifespan than the default "per-call" mode.The service as implemented currently uses a callback contract to send the results when they are ready.The client caches it's connection with the server so that they may be used for multiple requests. The connections are long-running.
Sindhudweep
OK - I don't think that's a very good idea, but I don't know the details of your setup; unfortunately, in WCF 3.5, there's not a whole lot of support for management and surveillance - this will be part of the "Dublin" project - a management add-on to IIS7/WAS scheduled to ship some time after .NET 4 (March 2010).
marc_s