.NET remote objects: Accessing same object by multiple clients

Status
Not open for further replies.

erikengh

Ars Tribunus Militum
2,280
Is it possible for multiple clients to access and modify the same remote object on a server?

I know it is possible for one client to connect to a server and then modify a remote object then disconnet and let another client modify the same object, but what I was thinking about was having multiple clients connected to the server at the same time.

If this is possible how do you make sure that one client doesn't read data from a remote object while another client modifies it? Is it possible to use Mutexes and Semaphores for instance?
 

erikengh

Ars Tribunus Militum
2,280
Of course reading should cause no problems. Reading never requires any kind of syncronization unless somebody writes or alters those objects.

So I am afraid that what your friend did is not the same thing I itendt to do.

I can give you a quick example of what I intend to do. I am making a Civilization like game, that is going to support multiplayer. So the game will run on a server which will have a client connected for each player. On the server there will be remote city, military unit, map etc objects. It is important to make sure that when one player alters a city another player doesn't read data from that city.
 

erikengh

Ars Tribunus Militum
2,280
PeterB and Sherrif, both System.Threading.ReaderWriterLock and ynchornizationAttribute is for threads right? I had a quick look at them but I can't see how they can help me. If I use a ReaderWriterLock on the client when I acces a remote object on the server how the hell is the other clients going to know that I have a lock on the remote object when the ReaderWriterLock object is local?

Or do you perhaps mean that I should insert the lock inside methods of the remote object?
 

DrPizza

Well-known member
93,870
Or do you perhaps mean that I should insert the lock inside methods of the remote object?
There should be a reader/writer lock either for the entire class or, if it's meaningful for multiple updates (on different members) to be performed simultaneously, for each member. Any mutating member acquires the write lock, any non-mutating member acquires a read lock.
 
Status
Not open for further replies.