Sindhudweep
Sindhudweep

Reputation: 784

Obtaining a list of connected clients for a wcf service

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.

Upvotes: 5

Views: 4218

Answers (2)

marc_s
marc_s

Reputation: 755321

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.

Upvotes: 2

nitzmahone
nitzmahone

Reputation: 13950

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.

Upvotes: 1

Related Questions