A “Quick And Dirty” Console Application Using The LiveFX

By ScottIsAFool | In Developer | Posted November 10, 2008 1 comment

This post is really just a starting point on using the LiveFX. Now, although I’ll show you a quick application, you won’t be able to use any of this just yet unless you have been given a LiveFX token (which you would redeem at the Azure Dev Portal). This framework also works with the Live Mesh client, although you don’t need Live Mesh to be installed for it to work.

For this simple demo, I’ll do a console application that will print out my name, my email address (which will be blurred :P ), my current Messenger PSM (Personal Message Status), and the number of contacts I have.

Because this is mainly for those who already have access to the LiveFX ‘bits’ I will assume at this point that you have already downloaded and installed the relevant prerequisites.

The code for this is very simple:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.LiveFX.ResourceModel;
using Microsoft.LiveFX.Client;
using System.Net;

namespace MeshConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            LiveOperatingEnvironment loe = new LiveOperatingEnvironment();
            string uriResponse = "https://user-ctp.windows.net";
            NetworkCredential creds = new NetworkCredential("WLID",
                                                            "PASSWORD",
                                                            uriResponse);
            loe.Connect(creds);

            // This gets the Messenger PSM
            Profile prof = loe.Profiles.Entries.Single(e => e.Resource.Title == "GeneralProfile");
            var _messengerPSM = (GeneralProfile)prof.Resource.ProfileInfo;

            // Prints the user's name
            Console.WriteLine("Details for " + loe.Mesh.ProvisionedUser.Name);
            // Prints the email address
            Console.WriteLine("Email Address: " + loe.Mesh.ProvisionedUser.Email);
            // Prints the Messenger PSM (gained above)
            Console.WriteLine("Messenger PSM: " + _messengerPSM.PersonalStatusMessage);
            // Prints the number of contacts I have with this WLID
            Console.WriteLine("Number of contacts: " + loe.Contacts.Entries.Count());

            Console.ReadLine();

        }
    }
}

Now, in the NetworkCredential object you would put your WLID and password in (mine are removed for obvious reasons). The results of this look as follows:

LiveFXConsoleAppScreenshot

MessengerPSMStatus

As you can see, the PSM taking what mine currently says.

This is only really scratching the surface of what the LiveFX can actually do but is a nice way to quickly get started.

SL

Posted November 10th, 2008 at 6:21 pm
Category: Developer
Tags: Live Mesh
  • http://www.liveside.net/members/cJr/default.aspx cJr

    Very handy post Scott, thank you very much.