Cloud, Development, General, user group, Videos, Windows, Windows 8

Microsoft DevRadio: Community Corner – How I created my Windows 8 app for UserGroup.tv

This entry is part 1 of 3 in the series Dev Radio: Community Corner

I had the great pleasure recently to interview Microsoft C# MVP Shawn Weisfeld as part of the Microsoft DevRadio show to hear about the Windows 8 app he built for UserGroup.tv. Tune in and listen to this great story as Shawn describes his experience building the app and how you can watch great user group created content anywhere, anytime.

Next Steps:

Subscribe to our podcast via iTunes, Zune, or RSS

 If you’re interested in learning more about the products or solutions discussed in this episode, click on any of the below links for free, in-depth information:

 Websites:

 Videos:

 Virtual Labs:

Download

Azure, Cloud, Development, Product Announcements

New Azure SDK and Services Updates

Some AMAZING new updates to Windows Azure were announced yesterday. I LOVE the rate at which new and improved features are being added to the Windows Azure platform, and I think you’ll find these updates particularly compelling. In a nutshell, here’s what was announced:

iOS Support for Windows Azure Mobile Services

The team released a native iOS SDK is for developers programming in Objective-C on the iPhone and iPad platforms. Included in the SDK are support for all the same features you get with the Windows 8 around data storage, dynamic schematization and authentication. Each Mobile Service can actually support *all* available clients, which now includes iOS, and it does NOT require a separate Mobile Services project for each different client. You can get sample code for each platform from the Mobile Service simply by toggling a switch:

While the release is still in development, and should not be considered a “final product”, the bits are pretty solid and the sample app worked for me without issue. I’m looking forward to them adding support for Notifications, which is missing from this current release, but should be coming out soon.

New Authentication Providers

Supported in both the Windows Store and new iOS bits, a set of new authentication providers have been added to the Mobile Services SDK. New providers include Google,  Twitter and Facebook, to augment the already existing Microsoft Account capacity.  Using the new provider model is really simple – first, you update the Mobile Services portal with the API keys that correspond to the types of authentication your application supports:

Then, you add code similar to the following, to process the login with the selected authentication provider:

private MobileServiceUser user;

private async System.Threading.Tasks.Task Authenticate()
{
    while (user == null)
    {
        string message;
        try
        {
            user = await App.MobileService
                LoginAsync(MobileServiceAuthenticationProvider.Facebook);
            message = 
                string.Format("You are now logged in - {0}", user.UserId);
        }
        catch (InvalidOperationException)
        {
            message = "You must log in. Login Required";
        }

        var dialog = new Windows.UI.Popups.MessageDialog(message);
        dialog.Commands.Add(new UICommand("OK"));
        await dialog.ShowAsync();
    }

}

Pretty simple!

Service Scripts Update

Some great new functionality is now available in the Mobile Service script layer.  These scripts are triggered off of any CRUD operation on a Mobile Service’s table and can already handle doing data and query validation, filtering, web requests and more.  The update now brings script access to blob storage, service bus, table storage, and more.  In addition, SendGrid and Twilio are now modules that can be called from the scripts, giving developers the ability to send emails (SendGrid) or SMS text messages (Twilio) whenever a script is fired.

Updates to the Windows Azure Training Kit

Along with all the updates to the SDK, there are also some updates to the Windows Azure Training Kit.   With this latest refresh, the kit now contains 38 presentations, 24 demos and 47 Hands-on Labs.  Speaker notes have been added to may of the presentations, and man of the labs have been updated to reference Visual Studio 2012.

SO GO GET IT ALREADY!

If you don’t already have a Windows Azure account, sign up today for a FREE 90-Day Trial at http://aka.ms/thecloud and get to work trying out some of these cool new features! You’ll get access to all the Windows Azure services for 90-days with a “spending limit” cap put in place once the trial expires to make sure that your credit card is not charged for any services without your explicit permission.  It’s a no-risk offer that you should jump on ASAP!

Azure, Cloud, Design, Development, Events, Oklahoma, TechFest, Tulsa, user group, Windows 8

Tulsa TechFest 2012

Tulsa TechFest is the premier technical conference in eastern Oklahoma, boasting “the broadest topics in the United States, maybe the world”. Sporting a healthy 18 separate tracks across multiple disciplines including  architecture, software and web development, databases, project management, security, social media, mobile, enterpreneurs, managers, BI & reporting, mentoring and even  a special Windows 8 Track, Tulsa TechFest is one of the largest events of its kind.

It’s primary focus is to provide training/teaching sessions that are immediately beneficial to the broadest range of IT professionals in their day-to-day jobs. They accomplish this with over 40 national/international speakers covering this wide range of topics over 90 to 120 75 minute sessions.

As with all conferences of this type, there is a cost associated with attending.  This year, in keeping with the traditions of the previous 4 years, attendance at the Tulsa TechFest will require you to pay your choice of $2, to be donated to the John 3:16 Mission, or 2 cans of food, to be donated to the Community Food Bank of Eastern Oklahoma. Last year, the event collected 469 pounds of food, and our target this year is to DOUBLE that amount, so please bring whatever you can to support these worthwhile charities.

This is the one that started it all, folks – since their first event, many other communities have been following our example by hosting their own TechFest events including VancouverTechFest, HoustonTechFest, DallasTechFest, AlbertaTechFest, IndyTechFest, and NWA TechFest.

I myself will be featured in the Cloud track talking about Windows Azure, including deep dive sessions on Windows Azure Caching, Access Control Service, Service Bus and Windows Azure Mobile Services.

This is one event you *won’t* want to miss – so sign up today at http://tulsatechfest.com!

Azure, Cloud, Development, MVVM, Open Source, Silverlight, USCloud, Windows, Windows 8, WP7, WP8

Scaling Collaborative Applications

One of our local MVPs, Michael Perry, has written a great article about scaling collaborative Windows 8 applications with Correspondence and Windows Azure.

Azure is a great way to quickly deploy and scale your web sites. Correspondence is a rich framework for bringing collaborative experiences to multiple platforms. When these two come together, amazing things can happen.

http://qedcode.com/content/scaling-collaborative-applications-azure-and-correspondence

For those that don’t know, Correspondence is Michael’s innovative collaboration framework for occasionally connected smart clients and web applications. Correspondence is hosted on CodePlex at http://correspondence.codeplex.com/ and samples can be found on Michaels blog at http://qedcode.com.

Azure, BootCamp, Cloud, Dallas, Development, Events, Featured, Houston, Launch, Texas, Training

Cloud OS Signature Event Series

I hope to see many of you tomorrow and Wednesday at the Microsoft Cloud IS Signature Event Series in Dallas and Houston. For those attending, here are some helpful tips on getting ready to attend.

Preparation

Although we don’t expect that you have a lot of background on Cloud Computing, or Windows Azure specifically, this event is primarily a HANDS-ON event, so it’s important to come physically prepared.  You’ll need a computer with at least Windows Vista SP2 pre-loaded with the Windows Azure software.  You can get the software from http://aka.ms/GetAzureNow – just click the .NET link from the menu of choices to get started. Any prerequisites for running the Windows Azure Development SDK will be installed automatically for you, thanks to our awesome Web Platform Installer technology.  PLEASE do this BEFORE you come to the event as it will save a BUNCH of time getting you ready for the labs.

Azure 90-day Free Trial

You can also get a FREE 90-day Azure Trial to use for this event, and your experimentation in Windows Azure. Just following the following link to get started:

http://aka.ms/TheCloud

Once you get signed up, navigate over to your Account page and choose the “Preview Features” link at the top. From here you can sign up for Windows Azure Web Sites, Virtual Machines, Mobile Services and more. These requests can take some time to process, so you should sign up sooner rather than later to make sure you’re account is ready to go.

Labs

As I mentioned before, this event is primarily a hand-on experience, so you’ll need to get copies of all the labs prior to firing up Visual Studio.  The labs are kept in a GitHub repository called WindowsAzure-TrainingKit.  The TrainingKit contains a METRIC TON of content, so to make things easy, here are links to the labs so that you can download them without hunting through the entire list.

  1. HOL – Introduction to Windows Azure Cloud Services
  2. HOL – Introduction to Windows Azure SQL Database
  3. HOL – Introduction to Windows Azure Virtual Machines
  4. HOL – Introduction to Windows Azure Access Control Service
  5. HOL – Service Remoting with Windows Azure Service Bus

These links take you to the “home page” for each of the labs.  If you’re familiar with GitHub and how to use Git, you can clone these repositories locally and open the assets from there. Alternatively, you can click the big ZIP button on each page and download a ZIP version of each of the HOLs. If you want to start over, you can just download a new ZIP file and be on your way.

Dependencies

For each of the labs, there is a setup.cmd file that you’re supposed to execute to get your machine prepped for the labs with all required dependencies. Unfortunately for some, these labs are still set up to expect Visual Studio 2010, not Visual Studio 2012, so the setup.cmd will FAIL on those.  If you’re running VS2010, run setup.cmd and you should be good to go.  If you’re running VS2012, here’s how you get your environment updated:

Option 1 – Snippets Only

  1. Open the Lab folder in Windows Explorer
  2. Locate the Source\Setup\Scripts\snippets\ folder (if none exists, there are no snippets for that lab)
  3. Manually run the VSI file to install the snippets.

Option 2 – Major Surgery

  1. Locate the Source\Setup\Scripts folder
  2. Edit the installCodeSnippets.ps1 file in Notepad, or your favorite text editor
  3. Replace all occurrences of “Visual Studio 2010” with “Visual Studio 2012”
  4. Run the Setup.cmd from the root folder, ignoring errors about the compilation of the SecurityTokenVisualizerControl
  5. Locate the Source\Assets\SecurityTokenVisualizerControl folder
  6. Open the SecurityTokenVisualizerControl.sln file
  7. Rebuild the solution – it *should* compile just fine
  8. From within this same solution, open the Toolbox window
  9. Right-click on the empty toolbox area and select “Add Tab…”
  10. Type in “ACS” into the new tab
  11. Right click inside the tab and choose “Select Items”
  12. When the toolbox loads, press the “Browse…” button, and navigate to the bin directory of the SecurityTokenVisualizerControl project folder.
  13. Select the SecurityTokenVisualizerControl.dll and press “OK” to close.

Additionally, the Identity and Access controls for Visual Studio 2012 are much different than the Add STS Reference controls from Visual Studio 2010. You will have a completely different process for enabling ACS in your VS2012 project than you did in VS2010.  To this end, I will probably walk through a sample application in Dallas or omit the session all together. The labs take a lot of time anyway, and feedback from the first 2 events was that we have WAY too much in the agenda already 🙂

Anyway…

I hope this helps you get what you need downloaded and installed for the sessions this week. You can, of course, download everything prior to attending, which would REALLY help move things along during the sessions.  In Houston, we’ll have a slightly different schedule in that we’re removing the ACS session in favor of boosting the times for some of the other sessions, but you’re welcome to work on whatever makes sense to you at your own pace. That’s the beauty of the Hands-on Lab approach – you can get hands on with the technology in a semi-structured environment as well as having the ability to go home and work on this stuff at your own pace on your own schedule.  I’ve personally learned a lot from these HOLs as I’ve ramped up on Azure over the past few months, and I highly recommend them to you.

Azure, Cloud, Dallas, Development, Events, Featured, Open Source, Students, Texas, Training, user group, Windows 8, WP7

Upcoming User Group Meetings

There are a couple of great-sounding User Group meetings coming up this week that I thought you all might be interested in:

Windows Phone App Developer Group – DFW Dallas TexasSeptember AT&T Mobile App Hackathon Education (Dallas)Friday, 5:00 PM Sep 14
Dallas PHPAn Illustrated Git PrimerTuesday, 7:00 PM Sep 11
DFW C++ User Group, meeting at NCR’s officeLeak Free C++Tuesday, 6:00 PM Sep 11

If you a new to Git, I highly recommend attending the PHP User Group’s presentation. The speaker and I have had numerous conversations about Git, and he does a really good job of explaining the basics. I was going to go and try to ask some of my newer questions about different workflow strategies, branching and such, but a prior family obligation is going to keep me from attending any groups on Tuesday night.

If you’re a Windows Phone or Windows 8 developer, I’ll also recommend the AT&T Mobile Hackathon. I’ve participated in these before and they are very well run by the gang over at AT&T and I know you’ll have an amazing time participating. The prizes are usually pretty good too, so bring your great idea and be ready to crank out some code!

These are just a couple that popped into my Inbox this morning, but there are plenty of other amazing activities to be found around TX, OK, AR and LA – just check http://southcentralcommunity.com and http://communitymegaphone.com for more details.

Cloud, Development, Featured, MVVM, Windows, Windows 8

Windows 8 Games and Roaming Data

I was recently asked to write an article for our upcoming 30-to-Launch series about using RoaminData in a Windows 8 game. Here’s that article and a link to the code.

Every game is unique, and carries with it a unique set of game data to save and load at various points of the games lifecycle. In the past, most gamers – especially casual gamers – had only one device on which their favorite game was installed. Data storage for those games was simpler for developers to manage in that the game data could be saved locally in a variety of formats, and loaded when the game started or at the user’s request, and was all self-contained within the game itself. Today, with people owning multiple devices both at work and at home, game experiences are more challenging to manage as users want to be able to share game data between different computers without having to store that data on some external device like a thumb drive or portable hard drive. Although there are a variety of custom code solutions that could be developed to support the sharing of game data between computers, WinRT provides a set of classes that facilitates this type of data sharing automagically – it’s called the Windows 8 Roaming Data Store. In this article, we’ll look at a simple game implemented for WinRT that uses the Roaming Data Store that enables a player to stop gameplay on one machine and resume it on a second.

Enter the Game

For this article, we will be using a very basic WinRT game based on the popular game Bulls and Cows, often referred to as Mastermind, to illustrate how game data can be saved and shared using the different features of the Roaming Application Data Store in WinRT.

Figure 1 – Sample Mastermind Game

Gameplay is very straightforward – the computer draws a random set of 4 colored boxes from a set of 6 different color choices to form a “code”. The player, often referred to as the code breaker”, provides a series of “guesses” to the solution by selecting a combination of 4 colors via the large buttons on the bottom that the game engine will test against the solution. The player will receive one red indicator for each color the player selects that represents the proper color at the proper position in the solution, and one white indicator for each color the player selects that is part of the solution but NOT in the proper location. In the sample above, the player was able to solve the game in 7 tries using deductive reasoning based on the red and white indicators for each of their guesses. For our game, we want to create an environment where the user can save off their current game state, and restore it on a different computer at some time in the future. To understand how to achieve this, you first have to understand how the Roaming Application Data Store works on WinRT.

Roaming Application Data Store on WinRT

The Roaming Application Data Store is part of the larger WinRT Application Data Store that provides data synchronization between computers sharing a common application. The data is synchronized through the use of a shared cloud storage area attached to a user’s Microsoft account.

Figure 2 – Synchronizing Data via the Roaming Data settings

The Application Data Store is comprised of three separate data storage areas:

  • Local Settings – data that is stored and scoped locally to this single instance of an installed application
  • Roaming Settings – data that is shared between devices on which the user has installed a particular application
  • Temporary Settings – transient data created by the application, stored and scoped locally to a single machine, and could be deleted by the OS at any time

Each of these three data stores can be further broken down into App Files and App Settings.

App Settings

App Settings are stored in the registry, exposed to the developer as a set of simple Key/Value pairs into which any valid WinRT data type can be stored (if binary types are needed, the developer must use App Files instead of App Settings). App Settings support the concept of Containers, into which sets of related App Settings can be organized and stored together. A default container is used when none is explicitly specified, or developers can create their own containers up to 32 levels deep to better organize their application settings. Composite Settings can also be used to support atomic updates of related settings to ensure data consistency during concurrent access and roaming.

App Files

The Files interface gives the developer a way to store serialized objects, data files, or other complex objects using the familiar File patterns. Under the covers, App Files are stored on the file system in a hidden folder on the user’s computer, located beneath the application’s installation directory. Files can be listed, created, deleted and updated using the classes in the System.IO namespace.

Both App Settings and App Files are automatically synchronized between machines on which the application is installed. By simply writing to the App Settings or App Files within the Roaming Data store, data synchronization is automatic.

Using the Roaming Application Data Store in the game

NOTE: You can download the code sample that goes with this post from CodePlex at the following URL:

http://win8roamingstorage.codeplex.com/

The first step to incorporating roaming data was to get the game up and running with all the basic features and decide on what bits of state I needed to save. I wanted to make sure that I had something simple to serialize and deserialize from storage, and I also wanted to experiment with both App Settings and App Files to see which ones worked better for different situations.

Saving Game State

Since my game logic was stored in a separate set of classes from the application UI, and I had used the MVVM pattern for managing application state for data binding, I had everything I needed in one place – the ViewModel. I was tempted to just save off the entire MainViewModel itself – all in one chunk – but decided instead to save off pieces of it to save space (see Observations: Quota below). My MainViewModel does a lot more than just hold state, so I selected just the bits I needed to persist into roaming storage. So, after every move that was submitted by the player, I called out to the following method:

private async void SaveGameState()
{
	StorageHelper.SetGameInProgress();
	await StorageHelper.SaveObjectToRoamingFolder(STR_Gamejson, _game);
	await StorageHelper.SaveObjectToRoamingFolder(STR_Movesjson, Moves);
	StorageHelper.PutObjectToSetting<string>("MoveSlotOne", MoveSlotOne);
	StorageHelper.PutObjectToSetting<string>("MoveSlotTwo", MoveSlotTwo);
	StorageHelper.PutObjectToSetting<string>("MoveSlotThree", MoveSlotThree);
	StorageHelper.PutObjectToSetting<string>("MoveSlotFour", MoveSlotFour);
}

This method uses a helper class I created to save App Files and App Settings into the roaming data store.

First, we tackle saving a file to the Roaming Folder. I’ve got two examples in my source code for this – first is the Game object that tracks the current state of the game including the current solution, history of moves, number of moves remaining, etc. The second is the PlayerMoveViewModel objects stored in the Moves collection. These are wrappers around the GameMove objects that contain UI-friendly representations of the Move data as well as the corresponding MoveResults (i.e. # of white and red indicators). The method used here is SaveObjectToRoamingFolder on my StorageHelper class:

public async static void SaveObjectToRoamingFolder(string filename, object o)
{
	var appData = ApplicationData.Current;
	string jsonData = await JsonConvert.SerializeObjectAsync(o);
	StorageFile sampleFile = await appData.RoamingFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
	await FileIO.WriteTextAsync(sampleFile, jsonData);
}

I’m using Json.NET for my JSON serialization needs as I’ve used it before, it’s fast, and easy to install via NuGet

. By using JSON, I minimize the size of each stored file to approx. 1KB for both the Moves collection and the Game object itself.

Next we tackle the four buttons the player was using to enter their guesses. I still feel that storing these settings are not specifically required from a usability perspective, but I thought it would add a nice touch to the game to have the board look exactly as it had before the player left it on their previous machine. To store these four settings, I decided to use the App Settings data store to see how that would work out. I extended my helper class with the PutObjectToSetting<T>() method to make this easy:

public static void PutObjectToSetting<T>(string key, T value)
{
	var appData = ApplicationData.Current;
	appData.RoamingSettings.Values[key] = value;
}

Short and sweet, this method simply attaches to the current RoamingSettings object and inserts a value according to a specific key if none exists, or updates the value of that key if already present. I’ve recently learned that people are calling this an “upsert”, although I’m not sure how I feel about that term 🙂

Loading Game State

Saving the game state was really easy – after every move, the game would save off the current state of the board and the 4 input buttons to the Roaming Store. Retrieving the data was a bit more challenging as I had identified 3 use cases for loading data:

  • Restarting the game on the local machine
  • Restarting the game on the secondary machine
  • Updating the currently running game on the local machine with data from the secondary machine.

The first two use cases are the primary use cases I identified for this game. I wanted to make sure that I could effectually stop the game on the local machine and restore it back to where I came from on the remote machine. I also wanted to consider the situation where I might pause a game on one machine and pick it up on another, only to come back to the first machine later. This was a bit more work, but ultimately boiled down to some additional code at launch time, and an event to register for while the app was running.

MVVM is a great pattern for separating UI logic from Application logic, but sometimes – as in the case of initially launching the application, there can be some overlap. My sample application uses the MvvmLight Preview library from Laurent Bugnion at GalaSoft (also available via a convenient NuGet package) to make this easier to manage. When my application launches, I use the MvvmLight Messenger object to send a notification to the UI that the user needs to be asked if they want to load the existing game, or start a new one when saved game state is found. I didn’t want to do this in the UI, which would have simplified the code, as I felt it broke the MVVM pattern and I wanted to keep to the pattern as much as possible.

So, in the constructor for the MainViewModel object, I register a listener for the GameBoardReadyMessage to check for existing game state and alert the UI if necessary. Otherwise, we trigger the beginning of a new game and let the user start entering data.

Messenger.Default.Register<GameBoardReadyMessage>(this, (message) =>
{
	if (StorageHelper.GameInProgress)
	{
		var msg = new AskForGameRestoreMessage();
		Messenger.Default.Send<AskForGameRestoreMessage>(msg);
	}
	else
	{
		StartNewGame();
	}
});

When the Main Page launches, it send a GameBoardReadyMessage when it’s ready to be loaded, and registers to listen for AskForGameRestoreMessage messages to arrive from the MainViewModel. When AskForGameRestoreMessage is triggered, the code-behind in the MainPage will prompt the user to confirm that they want to load the existing game (LoadSavedGameMessage) or start a new one (StartNewGameMessage). Depending on the answer, additional messages are fired to alert the ViewModel of the user’s selection. The path we want to follow here is the LoadSavedGameMessage path in the MainViewModel, as implemented in the LoadSavedGame method:

private async void LoadSavedGame(ApplicationData appData)
{
	try
	{
		CurrentGame = await StorageHelper.GetObjectFromRoamingFolder<Game>(appData, STR_Gamejson);
		CurrentGame.OnFailure += _game_OnFailure;
		CurrentGame.OnVictory += _game_OnVictory;
		Moves.Clear();
		var moves = await StorageHelper.GetObjectFromRoamingFolder<ObservableCollection<PlayerMoveViewModel>&t;(appData, STR_Movesjson);

		foreach (var move in moves)
		{
			Moves.Add(move);
		}

		MoveSlotOne = StorageHelper.GetObjectFromSetting<string>(appData, "MoveSlotOne");
		MoveSlotTwo = StorageHelper.GetObjectFromSetting<string>(appData, "MoveSlotTwo");
		MoveSlotThree = StorageHelper.GetObjectFromSetting<string>(appData, "MoveSlotThree");
		MoveSlotFour = StorageHelper.GetObjectFromSetting<string>(appData, "MoveSlotFour");
	}
	catch (Exception ex)
	{
		// show error message
		ClearSavedGameState();
		Messenger.Default.Send<ErrorLoadingGameMessage>(new ErrorLoadingGameMessage(ex));
		// start new game
		StartNewGame();
	}
}

In this code sample, we’re attempting to pull out all of the saved game state from both App Files and App Settings and reconstitute the game in progress. If anything goes wrong, we let the user know via an alert and just start a new game. The methods I added to the StorageHelper class do the reverse of the work we did to save the object to storage, and instead pull the data back out:

public async static Task<T> GetObjectFromRoamingFolder<T>(ApplicationData appData, string filename)
{
	StorageFile sampleFile = await appData.RoamingFolder.GetFileAsync(filename);
	string jsonData = await FileIO.ReadTextAsync(sampleFile);
	var o = await JsonConvert.DeserializeObjectAsync<T>(jsonData);
	return o;
}

GetObjectFromRoamingFolder<T> takes the data from the Roaming Store and uses Json.NET to turn that data back into the object of our choice (note that this method has to be marked as async because the underlying access to the RoamingFolder requires await).

public static T GetObjectFromSetting<T>(ApplicationData appData, string setting)
{
	var raw = appData.RoamingSettings.Values[setting];
	T obj = (T)raw;
	return obj;
}

Lastly, the GetObjectFromSetting<T>() method pulls back a value from the RoamingSettings collection and casts it into the proper type before returning.

Other things to consider

There are a few specifics related to the Roaming Data store that need to be considered before using its capabilities in your application. I didn’t account for all of them in my sample, but I wanted to list the more important ones here for you to consider when implementing Roaming Data in your game:

Quotas

Unlike data stored in the Local Data area, Roaming Data is governed by a storage quota

, as defined by the RoamingStorageQuota property of the ApplicationData object. This quota provides a maximum size for data that can be synchronized in the cloud via the Roaming Data store. As of this writing, the current RoamingStoreQuota value is 100KB. If this limit is exceeded, the application will continue to run but the data will NOT be synchronized to the cloud for access by other installations. For game data, this is an important consideration as you design your game. You’ll need to optimize the amount of data that is stored, and the serialization formats used, to ensure that you stay within this limit or risk shutting down the automatic synchronization.

Versioning

Games, just like traditional applications, evolve over time to take on new features, fix bugs, and improve gameplay. You should consider a versioning strategy for your Roaming App data just like you’d consider a versioning strategy for the game itself. The ApplicationData class provides a Version property as well as a SetVersionAsync() method to allow you to set a version on your data, and check in when loading the application data. If the version number of the stored data is less than the version your application is expecting, the app can either reject the saved game state in favor of a new game, or you can provide an update strategy to convert the old saved game data to the new format. Current guidance is to use sequential and incrementing version numbers, starting at 1, for your Application and ApplicationData versioning needs.

DataChanged event

Depending on how your game is intended to be used, there might be a situation where there is more than one concurrently running instance of your game. In this situation, the data synchronized via the cloud could be different or even older, than the data you’re working with locally. This could create a data collision of sorts, where the application will need to make a decision on how to proceed. To aid you in dealing with these collisions, the Roaming Data store provides a simple event to which you can connect an event handler to deal with this situation – the DataChanged event:

public event TypedEventHandler<ApplicationData, Object> DataChanged

By subscribing to this event, your application will be notified when the game state on another computer has changed, and you can respond accordingly. In my sample application, I respond to this event by calling into LoadSavedGame, passing in the provided ApplicationData object to refresh the game state and the UI.

Please note: The DataChanged event is NOT intended to be used to facilitate player moves in a turn based game. Not only is the game data synchronized for a single Microsoft account, the rate at which the updates occurs is not guaranteed to be timely enough for acceptable game play. There are other techniques, such as Sockets, that provide a much better alternative to creating networked turn-based games and applications.

Summary

This was a really fun project for me to do. I had never written a game at all before, in any shape or form, so I was concerned about that aspect of it as much as the strategies I’d use for loading and storing game state. I’ve posted all my code on CodePlex at the following URL for you to download and inspect at your leisure:

http://win8roamingstorage.codeplex.com/

Please keep in mind that this is not a “complete” game, in that it is not something I’d consider ready for the Windows Store (at least not yet) but it will be fun to continue working on it to get there.

More detail about the Roaming Application Settings, and the ApplicationData object can be found all over the web. Here are a list of additional articles, references and code samples to help you get started.

Azure, Cloud, Development, Product Announcements, Web

WebMatrix 2 + Windows Azure

WebMatrix 2 shipped this week with some new Windows Azure-related features!

For all the details, visit http://blogs.msdn.com/b/windowsazure/archive/2012/09/06/webmatrix-2-is-released-new-windows-azure-features.aspx

Here are some of the highlights:

  • Download Windows Azure Web Site applications to WebMatrix
    Windows Azure allows you to download your existing Windows Azure Website project into WebMatrix to work on locally or help you create a new project from the Application Gallery, or from a set of pretty cool templates.
  • Publish to Windows Azure
    Once you have an application downloaded, created from template or application gallery, or created from scratch, you can use WebMatrix to publish right back up to Windows Azure. You can import publish settings as downloaded from your Windows Azure Website dashboard, and publish right back up to the cloud. It’s really simple to use, and WebMatrix, like Visual Studio, is smart enough to only push the changed bits back to the cloud, optimizing the upload performance and getting your changes up and running as fast as possible.
  • Publish your Database
    Your application have a database with it? No problem! In addition to your published code, WebMatrix can also publish the scheme or database with your application

Congrats to the guys on the WebMatrix team! WebMatrix does more, of course, than just support Windows Azure applications, but you can learn more about that on the Web Matrix website as well as the new release announcement.

Azure, Cloud, Development, Windows 8

New Azure Stuff – WAMS and WATK

Hey – I’ve been travelling and presenting this week, so the Azure team decided it would be a good time to make a bunch of udpates!

Here’s a quick overview of what’s new, and where you can find more information:

Windows Azure Mobile Services

Windows Azure Mobile Services is a fantastic new feature added to the Windows Azure pantheon of services to provide an easy way to integrate a Windows Azure backend to new or existing Windows 8 clients.  Using the WAMS SDK, a developer can easily create a Windows 8 application that incorporates a Windows Azure SQL Database backend, WPNS and integrated Authentication & Authorization in a matter of a few minutes. The WAMS SDK comes with an upgrade to the Windows Azure Portal allowing the developer to configure the WAMS application’s Azure resources including SQL Database, Push and Authn/AuthZ API keys. Really simple to use and abstracts away all the complexities of connecting to a SQL Database instance from a Win8 app.  Definitely check this out!

  • Log into your Windows Azure account at https://account.windowsazure.com
  • Click on the “Preview Features” tab on the secondary navigation, just below the main nagvigation
  • Scroll down until you see the Mobile Services section and click “Sign Up”.

Activation doesn’t usually take too long, so you should be up and running in no time!  Once you’re activated, step through the WAMS tutorial on the Windows Azure website to get a full view of everything WAMS provides. This is going to be a big help to you Windows 8 developers out there, so get cracking!

Windows Azure Training Kit

A new version of the Windows Azure Training Kit dropped on Wednesday of last week.  The new kit is represented as the August 2012 Refresh, and contains some important updates including

  • Added the Windows Azure Device + Services 1-day event agenda
  • Added the Windows Azure ITProCamp 1-day event agenda
  • Added 2 presentations designed for Windows Azure Mobile Services
  • Added 15 Demos with Demo Scripts for content delivery

You can download the installer, or visit their project on GitHub to get just the pieces you want.

 

Azure, Cloud, Development, Events, Oklahoma, TechFest, Tulsa

Tulsa TechFest 2012

The conference season is really heating up!  I’ve just submitted a few sessions to Tulsa TechFest 2012 – so mark your calendars and sign up today!

When:  Friday, Oct 12, 2012
Where:OSU Tulsa Campus
How Much: $2 bucks, or 2 cans of food (donated to the Community Food Bank of Eastern Oklahoma)

David and company put on a great event every year – it’s got to be at least 8 years old now, and going as strong as ever! Make sure you sign up today, and tell all your friends about it!

Be sure to follow Tulsa TechFest on all the major networks:

Twitter Facebook LinkedIn