Be pushy with Push Notification in your Game: Class scope variables and HttpNotificationChannel

Part 2: https://aka.ms/PushyNotification

No matter what I have said in the past, XNA is going to be around for awhile in the Windows Phone 7.5, so let’s not leave opportunity on the table, open a New Project Windows Phone Game.  If you are using the Visual Studio 2010 Express for Windows Phone, you will need to download the C# Express (2010) package to get everything to work. 

FYI: This article does end with complete code and the expectation that you need the code to make things understandable, but to keep the article short and to the point, I have not included all of the code.

The minimum using you will need are, an the one extra is highlighted:

 using System;

using System.Diagnostics;

 using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

using Microsoft.Phone.Notification

 ;
 In the class scope area you will need to add a few variables, I have used a color coded approach, takes a bunch more time then normal, so might not continue with this style, it does clarify things visually
  Grey Lines are in program by default
 /// Lines that start with /// are a special type of comments  when you put a comment after the <summary> tag line, the comment shows up in the intellisense
  String that will be used to store the notification string
  Memory allocation for the SpriteFont
  Boolean variable to hold the channel status
  Creates a notification channel between the Microsoft Push Notification Service and the Push Client and creates a new subscription for raw notifications.
  https://msdn.microsoft.com/en-us/library/ff402556(v=VS.92).aspx
  
     

public class Game1 : Microsoft.Xna.Framework.Game {

          

GraphicsDeviceManager graphics;

          

SpriteBatch spriteBatch;

          /// <summary>         /// Default message if URI isn't set up or if it is, then it will be used for the message from the client         /// </summary>         

string msgNotification = "Nothing Pushed from the Client Application, not an error";

          /// <summary>         /// Font used for message         /// </summary>         

SpriteFont msgFont;

          /// <summary>         ///          /// </summary>         

bool bChannelStatus = true

 ;         /// <summary>         ///      /// </summary>         

HttpNotificationChannel notifyChannel;

       

public Game1() {

  

To keep this simple, I don’t have the completed code yet, but will have it posted shortly on a later blog.