using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SuperSocket.SocketBase;
using SuperSocket.SocketBase.Provider;
using SuperSocket.SocketBase.Config;
using System.Reflection;
using SuperSocket.SocketBase.Metadata;
namespace SuperSocket.SocketEngine
{
class MarshalAppServer : MarshalByRefObject, IWorkItem, IStatusInfoSource
{
private IWorkItem m_AppServer;
///
/// Initializes a new instance of the class.
///
/// Name of the service type.
public MarshalAppServer(string serviceTypeName)
{
var serviceType = Type.GetType(serviceTypeName);
m_AppServer = (IWorkItem)Activator.CreateInstance(serviceType);
}
///
/// Gets the name of the server instance.
///
public string Name
{
get { return m_AppServer.Name; }
}
///
/// Setups the specified root config.
///
/// The bootstrap.
/// The socket server instance config.
/// The providers.
///
public bool Setup(IBootstrap bootstrap, IServerConfig config, ProviderFactoryInfo[] factories)
{
return m_AppServer.Setup(bootstrap, config, factories);
}
///
/// Gets the server's config.
///
///
/// The server's config.
///
public IServerConfig Config
{
get
{
if(m_AppServer == null)
return null;
return m_AppServer.Config;
}
}
///
/// Reports the potential configuration change.
///
/// The server config which may be changed.
///
public void ReportPotentialConfigChange(IServerConfig config)
{
m_AppServer.ReportPotentialConfigChange(config);
}
///
/// Starts this server instance.
///
///
/// return true if start successfull, else false
///
public bool Start()
{
return m_AppServer.Start();
}
///
/// Stops this server instance.
///
public void Stop()
{
m_AppServer.Stop();
}
///
/// Gets the current state of the work item.
///
///
/// The state.
///
public ServerState State
{
get { return m_AppServer.State; }
}
///
/// Gets the total session count.
///
public int SessionCount
{
get { return m_AppServer.SessionCount; }
}
StatusInfoAttribute[] IStatusInfoSource.GetServerStatusMetadata()
{
return m_AppServer.GetServerStatusMetadata();
}
StatusInfoCollection IStatusInfoSource.CollectServerStatus(StatusInfoCollection nodeStatus)
{
return m_AppServer.CollectServerStatus(nodeStatus);
}
public void TransferSystemMessage(string messageType, object messageData)
{
m_AppServer.TransferSystemMessage(messageType, messageData);
}
///
/// Obtains a lifetime service object to control the lifetime policy for this instance.
///
///
/// An object of type used to control the lifetime policy for this instance. This is the current lifetime service object for this instance if one exists; otherwise, a new lifetime service object initialized to the value of the property.
///
///
///
///
public override object InitializeLifetimeService()
{
return null;
}
}
}