Passing Lists to SQL Server 2005 using XML

by Cameron Albert 31. October 2007 14:44
Jon Galloway wrote up a nice article on passing lists in a stored procedure using XML and SQL 2005's ability to query XML. For anyone who ever wanted to pass an array to a stored procedure this a good read. :)

Tags: , , ,

ASP.NET Development | General

Engine Structure

by Cameron Albert 30. October 2007 00:05

I am structuring my PBBG game engine to be as flexible as possible in order to build various types of games. In order to do that I need to abstract out the components of the engine. Since persistent browser based games are, well, browser based, I decided to follow the normal n-tier model. I am creating a data tier, my actuall database, an application tier which is the engine and will handle client connections, authentication, commands and reading and writing to the database. On top of the application layer will reside the game layer which will be customizable libraries that will use and access the application layer. This follows along the MUD driver and MUD lib pattern where my engine will be the driver which will persist data and handle all communications and my MUD libs or games will be written in an OO fashion to take advantage of the game engine.

The engine is being written in C# and in such a way to take advantage of features of ASP.NET such as HttpModules and HttpHandlers. 

.NET PBBG Engine

by Cameron Albert 17. October 2007 23:48

In between updating Perenthia and adding new features I have been pulling parts of the code base into a more generic PBBG Engine I am writing in C#. I started working on it when I upgraded the Knights of the Realm game and used parts of it for Perenthia. I am hoping to put Knights of the Realm Beta 2 on the new engine once I get it finished.

I am building the engine as generic as I can but it will incorporate a base rules set and some basic concepts. The base objects will be Avatars, Places and Things. These objects will contain the properties required to function within the rules set and all objects will derive from a base GameObject class that will provide a properties collection for creating custom properties on derived game objects.

The game will be driven by commands sent from the client. Some objects will handle the commands in the engine framework while other commands will cause events to be raised that deriving implementations can handle and provide custom execution or additional execution of the commands.

The egnine will basically be a commands/rules processor that I will hopefully be able to build a variety of games on. I have plans and ideas for several types of games and do not want to continually build the same thing over and over, hence the PBBG engine. 

ASP.NET AJAX Server Controls and PBBGs

by Cameron Albert 1. October 2007 17:31

I ran into a major performance issue with the ASP.NET AJAX Server Controls while testing my persistent browser based game Perenthia. I had initially used update panels fro the various regions on the main game interface such as the player stats, map and chat window. Programming this was simple as I could do everything in the server side code and just send back the results. With the partial page rendering feature of the ASP.NET AJAX Extensions only the update panel html was sent back to the browser.

Once I moved the application into a production environment and had people on there playing and testing the web starting running out of memory, the application was consuming the server memory at an alarming rate. What was happening was that IIS would jump 1 to 2 MB of RAM for each request made by the client, that means every time someone moved on the game map 1 to 2 MB of RAM were being held and not released. I tried a bunch of different stuff from optimizing stored procedures to caching the map data but none of it helped.

I used Firebug to watch the AJAX request and response and to see if I could reduce that down some. The response was simply HTML fragments so I wasn't too worried about that but the request sent the entire ViewState up to the server with each post. The ViewState for the game page could be quite large since I was appending messages to the chat window which was a server control.

I was able to eliminate the ViewState issue with the chat window but the app was still consuming RAM and not releasing it.

I decided to try just a simple JavaScript only AJAX post using the Microsoft AJAX Client Libraries. After doing some basic tests on the chat window I decided to rebuild the game interface using only client side AJAX calls, no update panels. This has resolved the server memory issue, why, I am still not sure, must be something with the way the resources are handled in .NET. I have not encountered the slow downs or crashes from before and the app is actually running a little smoother on the front end as well.

What I settled on was a custom ASHX handler class that handles the commands from the client and returns JSON strings that the UI can then translate and use to update the interface components. I had to rebuild some of the interface components as JavaScript objects but overall it was the right choice. Not too mention that I can now use that same handler with other interfaces such as Flash or Silverlight.

In conclusion, while the AJAX Server Controls might work great for most web sites they are definitely not optimal for a persistent browser based game (PPBG).


ASP.NET Development | Game Development | General | Perenthia PBBG

ASP.NET AJAX Lessons Learned

by Cameron Albert 25. September 2007 17:40

I used the Microsoft ASP.NET AJAX Extensions pretty heavily for the user interface of my persistent browser based game Perenthia and after about two weeks of live server testing I have discovered some performance issues that may cause me to abadon the use of the UpdatePanel for straight AJAX calls using JSON objects.

The reason being is that I have UpdatePanels that update various sections of the game and instead of just setting a value as supplied from the server they send back the entire HTML blog of changed text. For orderinary web sites this wouldn't be a problem and in fact when allow them to perform faster. Since Perenthia is a little more interactive in so much as players can move around, which are post backs, and do battle, which are post backs, sending all this HTML back is causing too much bloat.  I am thinking of creating some very simple Javascript objects that I can send down from the server that will contain only values that need to be changed rather than HTML. This way I am not sending down tables, spans and the like.

Anyway, we'll see it how it goes, hopefully it will improve performance of the game because that is lacking right now. 

Tags: , , ,

ASP.NET Development | Game Development | General | Perenthia PBBG

Perenthia PBBG Released

by Cameron Albert 14. September 2007 16:51

After many, many long months of designing, writing, re-writing, scrapping and re-writing my persistent browser based game Perenthia has been released in a public Beta phase. Features will continue to be added over the next few weeks with the first of those features being quests that follow the main storyline.

Check out Perenthia PBBG

Adventures in Silverlight

by Cameron Albert 29. August 2007 17:19
I spent some time last night and today playing around in Silverlight to make a final decision on whether or not I will use it in my PBBG Perenthia. I had already started building out a Flash UI but just keep running into the same issues with Flash; the IDE sucks and I keep having to rebuild C# classes in ActionScript. So, I decided to dig a little more into Silverlight to see if using the 1.1 version would be feasible. The word from MS is that the beta 2 with a go live license should be available sometime later this year. That might work out pretty well for me and my current timeline. I have most of the server functionality for Perenthia complete but just can't find a UI combination that gives me what I want and keeps the overhead down. Anyway, I am going to spend the next few days playing around with a Silverlight UI and see if I can come up with something I can use in place of Flash.

Tags: , , , ,

ASP.NET Development | Game Development

Perenthia PBBG Flash UI

by Cameron Albert 26. August 2007 23:01

I've decided to use Flash to provide the UI for my persistent browser based game Perenthia. I went back and forth between Flash and AJAX and even looked into Silverlight a little and Flash just has the maturity needed for a good PBBG interface.  I originally had the main game UI written using AJAX but found it to be a little cumbersome when a lot of activity was occuring on the back end, just too much traffic generated for one user. I looked into Silverlight a little but I am going to wait until the 1.1 version is released so I can program in C# on the backend. Flash seems to be able to provide me with what I need and I wrote custom ASHX handlers on the ASP.NET side to handle commands from the Flash UI. The UI is basically just an advanced MUD client, in that the primary output is text based. However, with Flash I will be able to provide a better map and add some additional graphical features later on down the road. Since the command handler is a custom ASHX handler in .NET I could really allow any type of client to connect, as long as that client can send XML as an HTTP POST and receive the and parse the XML response from the page.

I will post a screen shot of the UI in the next day or so. 


Tags: , , , ,

ASP.NET Development | Game Development | General

Visual Studio 2008 Sivlerlight JS 1.0 Page ItemTemplate

by Cameron Albert 24. August 2007 13:23
I created a Visual Studio 2008 ItemTemplate for Silverlight 1.0 JS. The template creates a Page.xml and Page.js files for creating Silverlight 1.0 JS pages in an existing web project. I built this template for adding Silverlight 1.0 XAML pages to an existing ASP.NET project I am building using Visual Studio 2008. The web project is a 2.0 project so I can't reference the 3.5 JScriptSilverlightPage Item Template.


by Cameron Albert 17. August 2007 15:31
I am starting to look into Silverlight a little more now that I have the VS 2008 Beta 2 and the Expression Blend 2 Preview. I like that in Silverlight 1.1 you can code in C# rather than doing everything in XAML or JavaScript.

Tags: , ,

ASP.NET Development

Powered by BlogEngine.NET
Modified Theme by Mads Kristensen

About the Author 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:

Microsoft Silverlight 4 Business Application Development: Beginner’s Guide