You are on page 1of 41

Live Services

Synchronizing Life

Live
Framework .NET
API Kit
Agenda Live Services
Synchronizing Life

• Introducing the Live Framework API


Kits
• Live Framework Kit for .NET
– Overview
– Key Concepts
– Accessing Live
– Managing application’s data
– Sharing your data
Key Take away Live Services
Synchronizing Life

• .NET developers the .NET Client


Libraries to build their applications
• Provides a .NET friendly development
environment
• Consistent with the Resource Model
Live Framework Live Services
Synchronizing Life

Libraries
.NET FX 3.5 Silverlight JavaScript Client Tools &
Web Controls …
APIs APIs APIs Controls Services
Resource Model
Developer
ATOM JSON POX RSS Binary XML Portal
AtomPub FeedSync

Resource Introspectio
CRUD Sync URI-LINQ Triggers Auth/Z Hosting
Scripts n
Core Data Communications App Model Provisioning
User Mesh / Account
Identity P2P Catalog Management
Folders News
Device Mesh Notifications Hosting
Photos Favorites
Applications Presence Mesh Applications
Contacts Lists
App Data & Settings
Profile Calendar Visual Studio
Application Tools /
System Management Designers
Mapping

Search

Live Operating Environment


Analytics

CRUD Sync App Hosting CRUD Sync Hosting

Resource Resource Script Engine Auth/Z Local Store


Script Engine
Auth/Z Analytics

Cache … P2P File Sys …

Cloud Client Developer


Sandbox
Windows “Strata” Windows Embedded Windows Mobile Other
Live Framework API Kits Live Services
Synchronizing Life

• A set of libraries which can be used to


program using Live fx
• .NET, Silverlight and JavaScript
Libraries available today
• Work on various platforms and
programming languages
Libraries
.NET FX 3.5 Silverlight JavaScript Client
Web Controls …
APIs APIs APIs Controls

Live Framework
Live Services
Live Framework Client .NET Kit Synchronizing Life

Expose the core Live service in a cohesive and consistent


way with .NET

Make it easy and natural for .NET developer to consume


Live Services

Have a symmetrical programming model


Live Framework Live Services
Synchronizing Life

Libraries
.NET FX 3.5 Silverlight JavaScript Client Tools &
Web Controls …
APIs APIs APIs Controls Services
Resource Model
Developer
ATOM JSON POX RSS Binary XML Portal
AtomPub FeedSync

Resource Introspectio
CRUD Sync URI-LINQ Triggers Auth/Z Hosting
Scripts n
Core Data Communications App Model Provisioning
User Mesh / Account
Identity P2P Catalog Management
Folders News
Device Mesh Notifications Hosting
Photos Favorites
Applications Presence Mesh Applications
Contacts Lists
App Data & Settings
Profile Calendar Visual Studio
Application Tools /
System Management Designers
Mapping

Search

Live Operating Environment


Analytics

CRUD Sync App Hosting CRUD Sync Hosting

Resource Resource Script Engine Auth/Z Local Store


Script Engine
Auth/Z Analytics

Cache … P2P File Sys …

Cloud Client Developer


Sandbox
Windows “Strata” Windows Embedded Windows Mobile Other
Live Services
Synchronizing Life

Authenication
Web Applications Live Services
Synchronizing Life

• Authenticate as myself
– Use web authentication
– Web site has no access to my mesh

• Authenticate as a user on my site


– Use delegated authentication
– User controls access to his mesh

• Mesh enabled web sites authenticate same


as before
Smart Client Applications Live Services
Synchronizing Life

• Use either local or cloud mesh

• Local mesh is already authenticated

• Cloud Mesh
– App must get username and password
– Use those credentials to authenticate to
the cloud
Local or Cloud Connection? Live Services
Synchronizing Life

• Local connection
– Local data cache
– Use it when offline capability required
– Automatically syncs with the cloud

• Cloud connection
– No local data cache
– Use it when offline capability not needed
Live Framework .NET Kit Live Services
Synchronizing Life

• LiveOperatingEnvironment class
– Connect your application to the LOE

• Cloud Connection
NetworkCredential userCredentials = new
NetworkCredential(“Raymond@hotmail.com”, “ILOVEMHYMESH”);

LiveOperatingEnvironment loe =
LiveOperatingEnvironment .Connect(userCredentials);

• Local Connection
– Uses default user credentials
LiveOperatingEnvironment loe = LiveOperatingEnvironment.Connect();
Live Framework .NET Kit Live Services
Synchronizing Life

LiveOperatingEnvironment

Mesh Contacts Profiles ...

MeshObjects Devices News

NewsItems

Members

DataFeeds

DataEntries
Demo
Live Services
Synchronizing Life

Using Cloud vs Local


Live Services
Synchronizing Life

Collections are everywhere


Accessing Data Live Services
Synchronizing Life

• Contacts
foreach (Contact contact in loe.Contacts.Entries)
{
Console.WriteLine(contact.Resource.Title);
}

• Profiles
foreach (Profile profile in loe.Profiles.Entries)
{
Console.WriteLine(profile.Resource.Title);
}

• Mesh Objects
foreach (MeshObject mo in loe.Mesh.MeshObjects.Entries)
{
Console.WriteLine(mo.Resource.Title);
}
Demo
Live Services
Synchronizing Life

Enumerating Collections
Live Services
Synchronizing Life

Querying, Filtering and


Sorting
Simple Queries Live Services
Synchronizing Life

var myQuery = (from mo in mesh.CreateQuery<MeshObject>()


where mo.Resource.Type == "LiveMeshFolder"
select mo);

Returns IQueryAble<MeshObject> - No count returned

var execQuery = (from mo in mesh.CreateQuery<MeshObject>().Execute()


where mo.Resource.Type == "LiveMeshFolder"
select mo);

Returns IEnumerable<MeshObject> - Count is returned

var listQuery = (from mo in mesh.CreateQuery<MeshObject>()


where mo.Resource.Type == "LiveMeshFolder"
select mo).ToList();

Returns List<MeshObject> - Count is returned


Filtering and Sorting Live Services
Synchronizing Life

Parameter Description

Orderby Sort the output by the values in the given element arg,
where arg is a string.
Skip Skip the first arg results, where arg is a positive integer.

Take Return the next arg results, where arg is a positive


integer.
Expand Prefetch the specified resources in arg, where arg is a
property of the returned object. More than one resource
can be specified as long as they are separated by a
var mos = (from mo in mesh.CreateQuery<MeshObject>()
where mo.Resource.Type == "LiveMeshFolder"
select mo).Skip(12).Take(12).OrderBy(mo=>mo.Resource.Title);

Returns the second dozen MeshObject entries that are folders, and
sorts them by their Title element values.
Demo
Live Services
Synchronizing Life

Querying, Filtering and


Sorting
Live Services
Synchronizing Life

Mesh Objects
Live Framework .NET Kit Live Services
Synchronizing Life

• Mesh Object
– Contains application metadata
– Fundamental unit of extensibility, sharing and
synchronization
– Can be replicated across a set of devices
– Can be shared among users and applications
– Contains:
• Members, Mapping, News, DataFeeds, Activities

MeshObject pokerInfo = new MeshObject("PokerInfo");


PokerChip chip = new PokerChip();
pokerInfo.Resource.SetUserData<PokerChip>(chip);
service.Mesh.MeshObjects.Add(ref pokerInfo);

public class PokerChip


{ public int NumberOfChips {get; internal set}}
Live Framework .NET Kit Live Services
Synchronizing Life

LiveOperatingEnvironment

Mesh Contacts Profiles ...

MeshObjects Devices News

NewsItems

Members

DataFeeds

DataEntries
Live Framework .NET Kit Live Services
Synchronizing Life

• DataFeed
– Stores application information
• Metadata and blobs
– Receive update information
– Has Replication and synchronization capabilities
– A mesh object can have any number of data feeds
– Remember to add a DataFeed to a newly created
MeshObject

DataFeed newDataFeed = new DataFeed();


newDataFeed.Resource.Type = “LiveMeshFolder”;
newDataFeed.Resource.HandlerType = “FileSystem”;

meshObject.DataFeeds.Add(ref newDataFeed);
Live Framework .NET Kit Live Services
Synchronizing Life

• DataEntry
– Data Entries and stored in a DataFeed
– Lowest level of storage in a mesh object

// Read the file.


FileStream input = new FileStream(path + filename, FileMode.Open);
DataEntry dataEntry = df.DataEntries.Add(input, filename);
input.Close();

// Required to see user data on all devices/Live Desktop/Data Model Browser


dataEntry.Update();
// Make sure everyone is synchronized
df.SyncEntries.Synchronize();
df.Update();
Demo
Live Services
Synchronizing Life

Adding a Mesh Object


Live Services
Synchronizing Life

Resource Scripts
Resource Scripts Live Services
Synchronizing Life

• What are they?


– Small domain specific language
– Declarative way to interact with LOE
– Logical equivalent of batched procedures
• Why use them?
– Frees you from the lower level details of
the HTTP protocol
– Improves efficiency
– Extend the Request processing pipeline
with custom business logic
Resource Scripts Live Services
Synchronizing Life

• Declarative modeling for


– Control Flow Statements
• Sequence, Interleave, Conditional, CRUD
– Data Flow Statements
• Bind statements
• Run locally or on the server
• Can run as triggers
• Serialized as POX or JSON
Statements Live Services
Synchronizing Life

• SequenceStatement
– Sequentially executes child statements
• InterleaveStatement
– Executes child statements in parallel
• ConditionalStatement
– If … Else … execution
• CRUD statements
– Operate on resources
Client vs Server Live Services
Synchronizing Life

• Server Side Execution


– Script.RunAtServer(credentials)
– Single HTTP request/response

• Client Side (In Process) Execution


– Script.Run(credentials)
– Multiple HTTP requests/responses
– Each statement generates request
Triggers Live Services
Synchronizing Life

• Attach to a resource instance


• Pre and post logic on Create, Update
and Delete
Examples:
– Create a thumbnail after an image
resource is created
– Remove a folder if the last child object is
removed
Authoring and Running Live Services
Synchronizing Life

• Create the statement DOM


• Compile the DOM and generate the
ResourceScript instance
• Execute the ResourceScript instance
• If a trigger, attach to the resource
Demo
Live Services
Synchronizing Life

Using Resource Script


Live Services
Synchronizing Life

Membeship
Live Framework .NET Kit Live Services
Synchronizing Life

• Members
– Represents a Windows Live ID’s
membership in the MeshObject.
– New members have to be invited to be
part of the Resource
– Has a role based on the object.
• Full, Author Writer, Reader
if (!meshObject.Members.IsLoaded)
meshObject.Members.Load();

foreach (Member member in meshObject.Members.Entries)


{
memberObjects.Add(member.Resource);
Console.WriteLine(member.Resource.InvitationAccepted);
Console.WriteLine(member.Resource.Role);
}
Demo
Live Services
Synchronizing Life

Membership
Summary Live Services
Synchronizing Life

• Live Framework
– Allows you to integrate the cloud in a
cohesive and consistent way
– Enables you to move to the next inflection
point in the software industry
– .NET developers can use the client
Libraries to build their applications
• Start using it today, we want your
feedback !!
Call to action Live Services
Synchronizing Life

• Start using the Mesh today


– http://lx.azure.microsoft.com
• Download The Mesh SDK and the Live
Framework Client
– https://developer.mesh-ctp.com/
Developers/Developers.aspx
• Build an application
Questions?
Live Services
Synchronizing Life

You might also like