views:

210

answers:

3

I am currently coding an online turn based rpg for an assignment. In the game players can chat with each other and send their actions once they complete a turn. What is the best way to take care of the data exchange between the players. Sockets or storing all information in a database and the program periodically does requests to check for any updates? Unless there is a better approach.

Please note that the game is meant to be wide scale, i.e alot of players will be having a number of games simultaniously on the same sever, so I must try to be as efficient as possible.

+1  A: 

Use WCF if it is possible.

unforgiven3
Only limited to silverlight for the assignment
Drahcir
Drahcir - if you need to talk to a database, WCF is the best way to do it with Silverlight.
unforgiven3
Oh sorry misunderstood you, thought u meant wpf. My mistake
Drahcir
+3  A: 

In Silverlight, you can only connect back to the host that served the Silverlight app, so that rules out client-client sockets. Everything in your game (including chat) will have to go via a server.

Windows Communication Foundation (WCF) is quite nice to work with in Silverlight2. Having your game turn-based makes things a little bit easier because it means you dont have to maintain the exact same game-state between players in realtime (ie: not aiming for max 100ms latency).

geofftnz
+1  A: 

There are two major possibilities. You can apply the Sockets communication or you can use the Duplex WCF. Here are the tradeoffs:

Sockets => better performance over smaller productivity
Duplex WCF => worse performance but greater productivity

There are some great examples on the net for both scenerios but if decide on the WCF solution here are some of the resources:

A very good tutorial by Peter McGrattan.
Information about duplex WCF from msdn.

Przemek