3
\$\begingroup\$

I am making multiplayer (2 players) Minesweeper like the one that's available on MS Live Messenger.

Client side is going to be silverlight, server side will be MVC Application. Client (the one who is waiting for his turn) will poll server every X seconds to get current state, the other client (who's turn it is will post his click to server and than roles will reverse)

Now my question is: should domain model classes be the same for client and server side? I mean you need Minefield class on both sides, but while server-side class will have rules and logic, client-side will be more or less a data holder.

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

I suppose you could use the same objects on the client side to represent the state of the "game board", but the client shouldn't need much more than that. When a player makes a move (clears a block), the client should only need to issue a command to the server (with the payload being the coordinates of the block to clear). The server could then process the move, and the clients would download the new game board state. The game board state itself should not contain any logic, so it could be quite appropriately used by both the clients and the server.

\$\endgroup\$
0
\$\begingroup\$

I know the question is kind of old but...

I've found that having a common DLL containing domain model classes is useful. The server classes inherit from these and add some logic. The client classes also inherit from these and add some animation data to them.

For network performance reasons I had custom serialization and deserialization routines in the common DLL as well. Deserialization took a factory as parameter such that new objects were of the server or client type depending on usage.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .