tags:

views:

402

answers:

1

hello i have a desktop application that communicate with a wcf service that i building as well

i want to be able to manage the logged on users inside the server without a db (statefull server)

i also want the server to know how to handle 2 client from same computer, whats the simplest way of doing it?

i also have more than 1 service that the client work with (login service and app service)

is there any operationContext Property that can help me?

+1  A: 

Hello,

You can deffinetly manage the logged users inside the server. I have created a personal pattern for dealing with such situations, and it ussually goes like this:

  • create a client class inside the WCF server that will hold all the needed information about the client.
  • create 2 methods in the service: logIn, logOut. the login method should be able to gather all the informations about the client that you want to store. Make sure to define properties that can uniquely identify a client instance. When the client conencts to the server it calls the login method, allowing the server to gather and save the information from the client. If using callbacks, this is the place to save the CallBack context object, in the client obejt. You can now save the Client object in the WCF server instance (I use a dictioary). When the client logs out, it calls the log out method and the server removes the entry.
  • create a KeepAlive method in the server that regularry checks the connected clients to see if they are still connected (in case of network failure or app crash a client may not call the logout method).

I think this is the simplest way (not saying it's the best) to manage clients in the server. There is no problem with having multiple clients from the same computer (you save the Context when a client logges in) as long as you have a way of uniquely identify clients.

As for your last question, having multiple services should not be a problem. In fact you have the same WCF server with different contracts (and endpoints) for the different services you offer. ALl the contracts reside in the same WCF server instance so they all can access the connected client list.

If you have further questions, I would be happy to answer them.

AlexDrenea
what can i save from the operation context that will be unique to each user so i can identify him and load his context when he perform a server request ? cause i dont wand the user to send his identity in each request.
Chen Kinnrot
You don't need the user to send identity each request, bencause the comm channer remains open (That's the KeepAlive for).
AlexDrenea