Page 1 of 1

Client/Server Design Concept

Posted: Thu Mar 04, 2004 4:32 pm
by nebukadnezzar
I want to code a turnbased Card Game and i don't know how i should make my client/server design.

First of all This is my first question:

Should only the server calculate the game and send the info to the clients to show it. And the clients are only sending the commands to the server.
Or should every client calculate the game and if there are differences the server decides?

Posted: Thu Mar 04, 2004 6:41 pm
by saigumi
I'm not exactly sure what you mean by calculations, but if you mean things like randomizing the deck...

Send a seed that you will generate the deck "shuffle" to the clients. The clients would both randomize off this seed and therefore the deck would be in the same order on each client.

This would take a burden off the server, but be slightly less secure as someone could change the memory or the key and get their deck randomness out of sync.

The server could then verify the order when the clients draw. (if you want it to be that secure)

Re: Client/Server Design Concept

Posted: Thu Mar 04, 2004 8:00 pm
by rt
nebukadnezzar wrote:I want to code a turnbased Card Game and i don't know how i should make my client/server design.

First of all This is my first question:

Should only the server calculate the game and send the info to the clients to show it. And the clients are only sending the commands to the server.
Or should every client calculate the game and if there are differences the server decides?
it would depend on what kind of game you are creating.. for you case it will not require blazing speed so i would suggest letting the server do all the work. for example, the server would randomize the deck and then when a card is dealt it would send a CARD_DEALT packet to each client specifying which card was dealt and who it was dealt to. if the client wants to do something it should first send it to the server and if the action is allowed, then the server will send it back as a command packet such as PLAYER_RAISED_BET($50,playerid=2)

for realtime games like UT where you want to reduce lag a much as possible it doesn't matter if the client is out of sync for an update or two, so long as the server corrects it later.. but in realtime games like CLONES the clients can never ever be out of sync so a method like i proposed above is more suitable

as for security, you could perform a simple XOR on all network data using a randomized number from the server to protect traffic from sniffers. you could also compress the traffic with zlib for more protection 8)

rsa for strings!

Posted: Fri Mar 05, 2004 1:01 am
by buhatkj
i found and adapted a simplified form of RSA encryption for this same purpose. i havent integrated it in yet because i haven't tuned it for speed yet, but for a card game...no biggie eh? here is a link to the file from fmorg that contains this:http://buhatkj.dyndns.org:4242/tempfiles/fmorgUtils.h
hope it's of use :-)
-Ted

Posted: Fri Mar 05, 2004 1:14 pm
by nebukadnezzar
I have done an essay ("facharbeit" in german) in school about RSA and i think it is not very suitable to be effective in network.
because it increases the amount of data to transmit and takes a lot of cpu-time

your prolly right..

Posted: Fri Mar 05, 2004 7:54 pm
by buhatkj
yeh you are probably right about this, the routine i have is reasonably fast but under high load or on a slow network its overkill. as rt said above a simple XOR with a "key" of some kind is prolly good enough. all the same it only sorta half-assed rsa, so it may be a bit faster.
-ted

Posted: Tue Mar 23, 2004 3:16 pm
by rt
nebukadnezzar wrote:I have done an essay ("facharbeit" in german) in school about RSA and i think it is not very suitable to be effective in network.
because it increases the amount of data to transmit and takes a lot of cpu-time
I wrote an essay on RSA and quantum computers back when i was an undergrad student :D read it at the bottom of this page http://www.tomkorp.com/clones/links.asp