//----------------------------------------------------------------------------
//
// Copyright (C) Intel Corporation, 2011 All Rights Reserved.
//
// File: MpsInterfaceClientApi.cs
//
//----------------------------------------------------------------------------
using System;
using System.Xml;
namespace MPSInterfaceClient
{
class MpsInterfaceClientApi
{
#region DATA_MEMBERS
///
/// Mps's instance to access the MpsInterface.
///
private MPSInterfaceService mps;
#endregion DATA_MEMBERS
#region CONSTRACTOR
///
/// Constractor.
///
/// string, url of the Mps server
public MpsInterfaceClientApi(string url)
{
mps = new MPSInterfaceService();
mps.Url = url;
}
#endregion CONSTRACTOR
#region PUBLIC_FUNCTION
///
/// Get all contexts machines.
///
public void getAllContexts()
{
object enumerateContexts = new object();
XmlElement[] Any;
XmlAttribute[] AnyAttr;
string expTime = mps.EnumerateConnectedMachines(out enumerateContexts, out Any, out AnyAttr);
object EndOfSequence;
do
{
SystemType[] st = mps.Pull(enumerateContexts, "1", Any, ref AnyAttr, out EndOfSequence);
foreach (SystemType s in st)
{
Console.WriteLine("System: {0}", s.SystemName);
}
} while (EndOfSequence == null);
}
///
/// Subscribe machine for notifiction.
///
/// string, uri of machine to add in the list of machines.
public void subscribeForNotification(string delivery)
{
System.Xml.XmlElement[] Any = null;
System.Xml.XmlAttribute[] AnyAttr = null;
mps.SubscribeForNotifications(delivery, ref Any, ref AnyAttr);
Console.WriteLine("Subscribe: {0}", delivery);
}
///
/// Unsubscribe machine for notifiction.
///
/// string, uri of machine remove from the list of machines.
public void unsubscribeForNotification(string delivery)
{
XmlElement[] Any = null;
XmlAttribute[] AnyAttr = null;
mps.Unsubscribe(delivery, Any, AnyAttr);
Console.WriteLine("Unsubscribe: {0}", delivery);
}
///
/// Check if spesific machine is connected.
///
/// string, uri of specific machine.
public void isMachineConnected(string uri)
{
SystemType st = new SystemType();
st.SystemName = uri;
System.Xml.XmlElement[] Any = null;
bool flag = mps.IsMachineConnected(st, ref Any);
if (false == flag)
Console.WriteLine("This machine is'nt connected");
else
Console.WriteLine("This machine connected");
}
#endregion
}
}