4

What is a good way to track connected users to my WCF server. EX: I have user accounts that each have usage sessions. If a user has 100 sessions registered on his account, he can connect 100 times from the same username. Keeping track of connections is straight-forward. But what about how to keep track if a user disconnects? How can the server be notified that the TCP connection on the end user got terminated?

I am creating a handler for when the channel gets closed. But how can I now match something in the sender / EventArgs to meaningful connection data.

    OperationContext.Current.Channel.Closed += _Closed;
    private void _Closed(object sender, EventArgs e)
    {
    } 
nl-x
  • 11,762
  • 7
  • 33
  • 61
Vans S
  • 1,743
  • 3
  • 21
  • 36
  • Different context, but this sound like a duplicate of this http://stackoverflow.com/questions/5338842/detect-socket-disconnect-in-wcf or this http://stackoverflow.com/questions/665473/how-to-handle-wcf-client-disconnect – Patrick M Nov 09 '12 at 03:09
  • Don't understand the question of How can you match something to "meaningful connection data"? What is the data your looking to collect? – bbqchickenrobot Jun 16 '13 at 21:38

1 Answers1

0

you can save your connection channels in dictionary when connection created and remove it on this event. therefore you can track concurrent users ;)

Mostafa Soghandi
  • 1,524
  • 1
  • 12
  • 20