103 lines
3.3 KiB
C#
103 lines
3.3 KiB
C#
//----------------------------------------------------------------------------
|
|
//
|
|
// Copyright (C) Intel Corporation, 2011 All Rights Reserved.
|
|
//
|
|
// File: MpsInterfaceClientApi.cs
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
using System;
|
|
using System.Xml;
|
|
|
|
namespace MPSInterfaceClient
|
|
{
|
|
class MpsInterfaceClientApi
|
|
{
|
|
#region DATA_MEMBERS
|
|
|
|
/// <summary>
|
|
/// Mps's instance to access the MpsInterface.
|
|
/// </summary>
|
|
private MPSInterfaceService mps;
|
|
|
|
#endregion DATA_MEMBERS
|
|
|
|
#region CONSTRACTOR
|
|
|
|
/// <summary>
|
|
/// Constractor.
|
|
/// </summary>
|
|
/// <param url="url">string, url of the Mps server</param>
|
|
public MpsInterfaceClientApi(string url)
|
|
{
|
|
mps = new MPSInterfaceService();
|
|
mps.Url = url;
|
|
}
|
|
|
|
#endregion CONSTRACTOR
|
|
|
|
#region PUBLIC_FUNCTION
|
|
|
|
/// <summary>
|
|
/// Get all contexts machines.
|
|
/// </summary>
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Subscribe machine for notifiction.
|
|
/// </summary>
|
|
/// <param deilvery="delivery">string, uri of machine to add in the list of machines.</param>
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Unsubscribe machine for notifiction.
|
|
/// </summary>
|
|
/// <param delivery="delivery">string, uri of machine remove from the list of machines.</param>
|
|
public void unsubscribeForNotification(string delivery)
|
|
{
|
|
XmlElement[] Any = null;
|
|
XmlAttribute[] AnyAttr = null;
|
|
mps.Unsubscribe(delivery, Any, AnyAttr);
|
|
Console.WriteLine("Unsubscribe: {0}", delivery);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if spesific machine is connected.
|
|
/// </summary>
|
|
/// <param delvery="delvery">string, uri of specific machine.</param>
|
|
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
|
|
}
|
|
} |