Perenthia Update

by Cameron Albert 24. February 2008 00:23

I haven't decided yet but am considering using Silverlight 2.0 with the next release of Perenthia. I've completed a good portion of my PBBG engine that will drive Perenthia but want to be able to take advantage of some the features of Silverlight 2.0 to provide better user experience. One of the features that really interests me is the socket support for 2.0. Once I get the 2.0 beta 1 bits I am going to start playing around with running my PBBG engine on a socket server application I wrote for Flash. If all goes well I should be able to provide some better multiplayer features in Perenthia such as real time chat and possibly player vs player combat.

Perenthia will still primarily be a text-based game but Silverlight could allow me to bridge the gap between web and client software. 

Comments

2/24/2008 2:52:38 PM #

Rob

I'd love to here about the socket based server you wrote for Flash.  I've been considering something like this for SL2 myself.  I think there is going to be general interest for this sort of thing, especially as more people start to consider SL2 as a viable platform for online multiplayer games.

Rob United States

2/24/2008 3:24:14 PM #

calbert

I will post some more about it as I migrate code over into my game engine for use with SL2.

calbert United States

2/26/2008 5:29:48 AM #

Willie Tilton

I was looking to use a restful interface to save and interact with data.  Would this not work well?  The security issues with it might be a concern, except that I'm making a game and not something with sensitive data.  With SL2 they've allowed cross domain rest calls so I thought that'd be the answer.  Dealing with sockets I'd think would be a lot tougher?

Willie Tilton United States

2/26/2008 11:07:29 AM #

calbert

The only problem with REST or any web services is that it is one way unless you constantly poll the server. Using sockets is a lot harder but also allows the server to push information to the clients in a more real time fashion than polling would.
Most of it just depends on what you wish to accomplish. Using sockets opens up more multiplayer options since you can manage player interactions in real time instead of waiting for a user request.

calbert United States

2/26/2008 12:31:01 PM #

calbert

Don't get me wrong though, I am not saying a polling approach would not work. Perenthia uses that approach now, but allowing players to play against each other would require something a little more real time. For strategy or turn-based games though a polling service would probably work great.

calbert United States

2/26/2008 3:18:52 PM #

Ken

Will SL2 allow peer to peer socket connections?  A large game would seem to cripple the webserver if it had to maintain hundreds of those socket connections.  How does the Flash socket implementation handle this?  I can't wait to rip into SL2!

--- Ken

Ken United States

2/26/2008 4:04:20 PM #

calbert

I don't really know for sure what it will allow, I am just going on Scott Gu's post where he mentioned networking via sockets.
I would think you would want a server dedicate to handling the socket connections rather than having your web server handle all of that. Just depends what becomes possible with SL 2.0. I can't wait to get into it either! Smile

calbert United States

2/26/2008 4:19:28 PM #

Willie

Yeah, what I was mainly thinking of was just keeping track of scores or something easy, definitely not concerned with multiplayer stuff yet.  Sockets would allow this to be done a ton easier that something like REST.

Willie United States

2/26/2008 4:27:51 PM #

Willie

Oh, and wouldn't the server you wrote for flash be easily used with SL?  I mean nothing should change on the server side, just have to convert the client code.  Here's to hoping sockets got into SL2 Smile

Willie United States

2/26/2008 4:29:50 PM #

calbert

Perenthia currently uses AJAX to send data to a custom IHttpHandler that parses and processes the commands, the server is keeping track of all other data via the database. An encrypted string is sent along with commands to ensure that the command is executed for the currently logged in user and character instance.

The only problem with just allowing the client to post scores back to the server is that anyone could just send along their own scores. I would suggest just sending back the action the player chose and let the server determine the outcome and score based on persistent values.

calbert United States

2/26/2008 4:34:31 PM #

Willie

I agree.  That could happen.  Again though, if people really wanted to cheat they could find a way.  Couldn't I just send an encrypted string back through my REST interface?  In either case, couldn't they just sniff the packets and figure it out one way or the other?

What you could do is have the connection encrypted and then require some type of authentication, plus encrypted string values...but again...it's just a game.  How bad do these people want to cheat?

Willie United States

2/26/2008 4:36:33 PM #

calbert

I've ported most of the code from my Flash socket server over to my PBBG engine, which includes a socket component. Since Flash uses a zero byte terminator I stuck with that in my PBBG implementation and will just code my client to strip that byte off before deserializing the response. The server waits for that byte before attempt to process the command.

calbert United States

2/26/2008 4:41:52 PM #

calbert

People will always find a way to cheat but you don't want to make it too easy Smile

If you pass encrypted strings back and forth they would have to figure out your encryption and if they do that then they deserve to be able to cheat.

Anything that can be done can be undone but encrypting data would prevent someone from messing with someone else's scores, etc. Perenthia sends plain text commands back and forth that contain the database ID values. I really don't care if anyone figures out the IDENTITY of my records because without the encrypted authKey containing a set of credentials they can't do anything. Of course if they go through the trouble of attempting to sniff out other people's authKeys then they can cheat all they want, just not worth it for me to try and lock it down that much. Smile

calbert United States

Powered by BlogEngine.NET 1.5.0.7
Modified Theme by Mads Kristensen

About the Author

CameronAlbert.com I am Senior Software Development Consultant specializing in Silverlight, WPF and the Microsoft .NET Framework. 

I have released an iPhone game called the Adventures of Puppyman that was built using ExEn and am currently working on a WP7 and iPhone version of Perenthia soon to be released.

View Cameron Albert's profile on LinkedIn
See how we're connected

Follow cameronalbert on Twitter

 

Recommended Books

Silverlight 4 Business Application Development - Beginner's Guide:

http://www.packtpub.com/microsoft-silverlight-4-business-application-development-beginners-guide/book

Microsoft Silverlight 4 Business Application Development: Beginner’s Guide