Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use WCF to solve a server-client system that will share the same data source but will have separate instances/session for each client

Tags:

c#

wcf

I am creating a server client system in which the server is to host a service, I tried to use .net remoting as a means of communication but have encountered problems. I've used remoting in past projects but have decided to leave the remoting framework and switch over to WCF.

The system is designed as follows: The server is to host a service which allows clients to retrieve data from it. The service also store specific client instance variables that will allow it to treat clients separately (i.e different sessions). The service is meant to source this data from a database(compact database i.e .sdf) perform some logic and pass this data through classes/structs that can be used by the clients.

The most important goals are: -Make sure each client has its own separate session on the server. -Make sure all clients are serviced using the same instance of data source.

The other goal is to transport this data in binary format.

I have tried to read and understand want single-call and singleton mode means but each time I read a different material, the more I get confused and I'm still not convinced if either mode would solve my problem.

If there is anyone who understands my problem please explain to me the approach to use.

Thanks in advance.


Thanx a lot. I've gone through the first article (by @Timothy Khouri) and the features introduced is what I was looking for.

Secondly, I don't want the clients to share some data between themselves. If I understand the concept of session based clients, each client has a copy of its server object on the server machine. What I want is for this server objects to use the same linq2sql data object. Do I make the data object (linq2sql object) as a private static member? Or how should I go about it.

Also I wanted to use binary serialization because I tought it was more secure. I'm trying to prevent a situation where a hacker would get access to the shared classes and then have the ability to create his own version of the client app because I've assigned some security issues to be handled on the client side. Does/can the serialization method have any impact on this?

like image 625
Abdulmajeed Avatar asked Nov 13 '22 18:11

Abdulmajeed


1 Answers

This is exactly what I did for a company I worked for the past 3 years. Their architecture used to be a bunch of ASMX soap calls, and I changed it to a CONNECTED (which is what you're looking for), session-aware architecture using net.tcp (WCF).

I wrote some articles a few years back that explains is AND HAS A SAMPLE DOWNLOAD APP AT THE END OF THE ARTICLE that should get you started.

Client Server Programming with WCF

Duplex WCF Services Hosted in IIS Using Net.Tcp

The first one is probably what you're looking for in particular.

like image 107
Timothy Khouri Avatar answered Jan 02 '23 22:01

Timothy Khouri