SortDescription values null using Kendo UI and ASP.NET MVC3

I have been working on some admin screens for an internal application and we recently purchased the Telerik Dev Tools library for use on the site. The first scenario I tackled was displaying a list of the application’s active users.

The Kendo UI Grid supports both client side rendering and server side rendering.

Client-side rendering uses HTML/JS to setup the grid and then makes a remote call to load data into the Grid.

Server-side rendering a developer uses C# to setup the grid and populate its contents from a property on the Model.

At first, due to my natural preference for C# vs. JavaScript, I tried using the server-side rendering. The grid rendered with the data in it but sorting, filtering, and grouping did not work.

Next, I tried client-side rendering. I found this wonderful article describing how to setup your controller endpoints to take in the correct parameters that the Kendo UI Grid sends but I still had the same problem. Sort wouldn’t work. However, this time, I had a pretty good idea why.

Based on the fore-mentioned article, I setup my controller endpoint with skip, take, page, pageSize, sort, and filter parameters.

image

I defined SortDescription class:

image

Then I defined the FilterContainer and FilterDescription classes:

image

So far so good? Or so I thought…

I launch my site (in the Azure simulator of course Smile) and turn on the web console within FireFox so I can monitor the activity. I see the call come across from the Kendo UI JavaScript.

The Query String of the request looks like this:

image

All the usual suspects are there.

image

I even used a URL decoder ring to make it a bit more readable just to be sure I knew what I was looking at.

The URL looks okay but when my controller picks it up I have an array of SortDescription objects with one item in item. As expected. However, the Dir and Field properties are null. Based on the query string I am expecting Dir=”asc” and Field=”LastName”.

image

I thought the likely problem would be some serialization failure. So I tried modifying my SortDescription class to make directly to the case sensitive names.

image

But it makes no difference.

Posted in ASP.NET MVC, Telerik | Leave a comment

Windows Azure Multiplayer Game Event Notifications: Making it perform

As both the author of Game Fabric and games using the platform, sometimes I might be a better platform developer than a game developer. Smile

The GameFabric Action Service provides a mechanism to push down events to all the connected users in the game. These events then get picked up by your game UI and are used to update the visuals.

The GameFabric GameState Service provides a mechanism to capture game specific data and store it across all connected users.

This interaction can be thought of as a bucket full of water. Each action a player takes within the game adds a drop to the water in the bucket. Each action performed then gets dripped out of the bucket through a controlled down spout (the action service), allowing just one drop at a time out to be sent to multiple clients (the other players).

The water in the bucket, or the game state, represents a complete picture of the game. Each droplet, or action, represents one tiny step in the game’s history. These tiny steps can be used to update the user interface because they come with some context.

image

So what is the anatomy of an action? Well, its composed of three parts:

1. Player: who performed the action.

2. Verb: logical identifier to uniquely identify different types of actions

3. Parameters: collection of parameters to provide deeper insight into what the action should do.

image

The beauty of this approach is that, it doesn’t matter what your game is, you can use the action service to send the next event down to all your players’ phones. In Euchre, I designed 7 action verbs that my game client would handle. Pick, Call, Drop, Play, Match-Over, Round-Over, Game-Over. Each of these actions has some parameters that help my client determine what needs to be displayed to the user without going and grabbing a game state.

image

However, the way I originally wrote the Euchre client poorly leveraged this architecture. I added an 8th verb called ‘update-game-state’. This action was invoked after every other action and the client used this verb to simply call the game state service and download the latest game state. This made it simple to implement the client but did not make for great user experience.

Let me explain this anti-pattern in greater detail before I dig into why the approach sucked so bad.

image

Basically, I had a standard MVVM setup inside my game application. I registered with GameFabric to pull down events for the appropriate session but instead of handling the event feed, I lazily relied upon update-game-state to tell me when to go download the game state. I would download the entire game state, blow away the old game state, and update the UI entirely from the new game state. This is essentially, Save-Open-Save that we see in document-based applications.

A couple problems:

1. The UI was unresponsive during the game state loading and since the game state is updated very frequently this resulted in the graphics to appear jerky or sluggish to the user.

2. The communication was unnecessarily chatty. I used to see over 1000 actions in a single game session of Euchre. Now, Euchre averages about 300 actions. This significantly reduced the amount of usage I consumed of the cloud services that the platform is built on. And with my eCPM’s as low as they are, every little bit helps! Smile

My Solution

image

The platform was already doing the right things. I was getting distinguishable, parameterized actions for each action human or computer players made. However, my shoddy game logic within the Euchre Worker Role resulted in an 8th ‘update-game-state’ verb that caused all the problems. This anti-pattern verb became a crutch that I used to build the UI faster but not better.

I modified my Euchre Worker Role to only send absolutely necessary events. This means only meaty game related verbs needed to maintain context. I did not include any artificial verbs related solely to game functions like game state or UI cues. The latter, I avoided quite reluctantly as I briefly dabbled with the idea of using the action service to notify the UI of user input prompts. I decided against this approach for a variety of reasons (a topic I will reserve for a future post).

After I removed the crutch, my phone client now all but completely broken. I gutted the data bindings that drove many of the visuals and replaced them with imperative code that managed animations. I did keep some data bindings but only for text or other static content. All visual state changes or interactive elements were animated manually or using Visual State Manager.

It has been a lot of work, getting it right, and I still have a ways to go, but I am confident I am on the right path and my product both Euchre with Friends and Game Fabric will be leaps and bounds better than their previous versions.

Posted in Windows Azure, Windows Phone | Leave a comment

GameFabric Update

As many of my frequent readers may already know, my nights and weekends are filled with work on a platform I have dubbed GameFabric. Windows Azure powered multi-player gaming platform with client accelerators currently for Windows Phone and Windows 8.

I knee deep in a major optimization of the platform. In version 1.2 I plan to add a ton of bug fixes and new features. I am planning a joint release of my first game built with the platform Euchre with Friends.

I am making an overhaul to the Euchre client and server components to take advantage of the platform changes. Right now I am currently ironing out the bugs using the new ‘Watch’ feature which allows me to observe 4 computer players play a game.

This has prompted me to add some features to my administrative web site that I use to manage the production version of both GameFabric and each game. Previously, I only gave myself read-only access to key entities like Game Sessions, Users, etc. But I have seen the need to add key commands to the web site that allow me to spawn new simulated games (all computer players), start games that have otherwise been paused due to bugs in the Game Worker, and delete sessions outright.

All these features I plan on eventually including in a command center for game developers who use my platform to help them manage and test their games.

Posted in Windows Azure, Windows Phone | Leave a comment

Activating Windows 8 Troubles

I had some trouble activating Windows 8 through the metro settings interface but I found this worked great:

Open command prompt as an administrator and do this:

slmgr.vbs -ipk “YOUR-KEY-GOES-HERE”

Posted in Windows 8 | Leave a comment

Windows 8 + Azure Mobile Services Overview

For today’s weekly Windows Azure community call I decided to demo Azure’s new Mobile Services Feature. Microsoft provided a surprisingly easy tutorial to follow and I was able to get up and running within 30 minutes with an application that saves to Azure storage and authenticates using Windows Live (is it called that anymore, I’m confused).

Here is a high level overview of the tasks and where I hit bumps along the way.

Things you’ll need:

1. Windows 8 and Visual Studio 2012 installed

2. Mobile Services SDK

3. Live SDK

 

OK. Now that’s out of the way. Here we go. Down to business.

1. Register your application here.

There are apparently two ways to register apps. Using the link above provided all the settings and denoted my app as a ‘Windows Developer Preview Application’. Just going through the regular process seemed to omit that suffix from the name but most importantly certain settings were unavailable within API Settings. Most notably the Package SDI and Restrict JWT Issuing.

2. Enter basic application settings.

Make sure that the publisher name (CN-foo) that you enter matches what is in your project’s *.appxmanifest file! I made this mistake and got a vague error from the authentication attempt.

3. Update redirect domain in your application settings.

4. Update the client secret in your mobile services settings.

5. Modify your code to use the boilerplate authN code provided by Microsoft.

image

Microsoft has a nice TODO project that helps speed things along from a storage stand point. The download is accessible from within your very own Mobile Service. Just click ‘Create a new Windows 8 application’ to expand and show you the full details.

image

Posted in Windows 8, Windows Azure | Leave a comment

Game Fabric Update

Last post I outlined a couple major updates to both the Game Fabric framework and my first game built on the platform, Euchre. In my quest to add these features I am adding another feature that allows users not in a game to ‘watch’. This I hope will allow for more interactivity between players even when they are not playing each other and could help new users unfamiliar with the game get up to speed.

SNAGHTML80ab2f

An added side effect is the UI testing this will enable for me as I try to improve the sluggish performance of the game. I have already made a pretty massive overhaul of the event mechanism for the game which should reduce unnecessary chattiness. This is both good for the user and good for my pocketbook as every little storage transaction adds up!

In the local testing I am doing I have also found that a game averages about 350 actions. I send actions for the following events:

1. User decides whether or not to pick up the card and call trump

2. User drops a card (if they are the dealer and somebody told them to pick it up)

3. User calls trump (after the pick it up phase)

4. User plays card

5. Match is over (all 4 players play a card) culminating in a trick for the winner.

6. Round is over (all 4 players play all 5 of their cards) culminating in point(s) for the winner.

7. Game is over (one team has reached 10 points).

So how many storage transactions does that translate to?

  • 350 tx for storing actions in table storage
  • 350 tx for storing actions in blob storage
  • 600 tx for polling actions from blob storage (10 min * 60 s / min * 1tx / s)
  • 25 tx for getting list of players at start of each round

This means for every single player game I am seeing 1325 transactions. This is 0.1325 units of storage transactions or $0.019875 per game. Of course, in order to get total cost I would have to also look at outbound traffic, compute and storage. I am planning on moving my web services to Azure Web Sites to take advantage of the free tier hosting. That should help. But my workers are going to have to stay on in dedicated Extra Small compute instances. I’m not too worried about outbound traffic but if I want to squeeze more pennies out of my architecture I could replace my SOAP based web services with JSON based REST services. Naturally, JSON is much smaller serialization strategy than XML.

The real question is, how many impressions can I get in a game that lasts 10 minutes?

I think that if I can get this next release out with push messaging alerts, multiple simultaneous sessions, watch capability, and improved user experience I could get back on the rails from a customer satisfaction stand point.

Microsoft FINALLY approved the 1.1 updated I made to ‘Euchre with Friends’. The 1.1 version of Euchre is already seeing 3k impressions this month. That is half of last month’s total and we are just 7 days into the month. Hopefully this trend continues. I’m hoping to delight my customers with a 1.2 release by the end of September. Hopefully, they will come back after I get the kinks worked out!

Posted in Windows Azure, Windows Phone | Leave a comment

GameFabric Update

So I launched Euchre. With mixed success. SUCCESS: I have over 600 registered users within the first two months. FAILURE: Ad Revenue is extremely weak.

So why is my ad revenue so weak? I have a couple theories:

1. My eCPM sucks

2. People aren’t playing games

I can’t do much about my eCPM so I really need to focus on getting people playing my game! They download it, open it, open a session, leave and never come back.

Problem 1: They don’t come back

I am not using notifications to let people know 1) other people joined the game they created, 2) the session captain of the game they joined started the game, 3) it is their turn to act within the game. I know! How could I miss that? Alas, I cut it from scope to get out the door sooner.

Problem 2: Slow play is very, very common

I only allow a user to participate in a single session at a time. This limits the options in terms of game play. If the 1-3 other players in your one and only session are busy then you can’t play my game. I need to enable the user to participate multiple simultaneous sessions so that they can play when they want to play. That means bouncing between multiple sessions with other humans or even their local game. The fact of the matter is, people aren’t going to sit down 4 at a time and play my a complete game of Euchre.

Posted in Windows Azure, Windows Phone | Leave a comment