using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace SuperSocket.SocketBase
{
///
/// The status of one SuperSocket node (one installation or deployment)
///
[Serializable]
public class NodeStatus
{
///
/// Gets or sets the bootstrap status.
///
///
/// The bootstrap status.
///
public StatusInfoCollection BootstrapStatus { get; set; }
///
/// Gets or sets the status of all server instances running in this node.
///
///
/// The instances status.
///
public StatusInfoCollection[] InstancesStatus { get; set; }
///
/// Saves the specified file path.
///
/// The file path.
public void Save(string filePath)
{
var serializer = new BinaryFormatter();
using (var stream = File.Create(filePath))
{
serializer.Serialize(stream, this);
stream.Flush();
stream.Close();
}
}
///
/// Loads a NodeStatus instance from a file.
///
/// The file path.
///
public static NodeStatus LoadFrom(string filePath)
{
var serializer = new BinaryFormatter();
using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read))
{
var status = serializer.Deserialize(stream) as NodeStatus;
stream.Close();
return status;
}
}
}
}