Question

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.

Was it helpful?

Solution

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).

OTHER TIPS

Use WCF if it is possible.

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 McG.
Information about duplex WCF from msdn.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top