66 lines
1.3 KiB
C#
66 lines
1.3 KiB
C#
|
using System;
|
||
|
using System.Runtime.Remoting;
|
||
|
using System.Runtime.Remoting.Channels;
|
||
|
using System.Runtime.Remoting.Channels.Tcp;
|
||
|
|
||
|
namespace Novell.CASA
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// Summary description for RemoteServer.
|
||
|
/// </summary>
|
||
|
public class RemoteServer
|
||
|
{
|
||
|
|
||
|
|
||
|
TcpChannel channel;
|
||
|
public RemoteServer()
|
||
|
{
|
||
|
//
|
||
|
// TODO: Add constructor logic here
|
||
|
//
|
||
|
}
|
||
|
|
||
|
public void startServer(int port)
|
||
|
{
|
||
|
int iPort = port;
|
||
|
if (iPort == 0)
|
||
|
iPort = 8080;
|
||
|
|
||
|
channel = new TcpChannel(iPort);
|
||
|
|
||
|
try
|
||
|
{
|
||
|
ChannelServices.RegisterChannel(channel);
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
throw e;
|
||
|
}
|
||
|
|
||
|
// Register as an available service with the name HelloWorld
|
||
|
RemotingConfiguration.RegisterWellKnownServiceType(
|
||
|
typeof(SecretStore),
|
||
|
"enumerateSecretIDs",
|
||
|
WellKnownObjectMode.SingleCall );
|
||
|
|
||
|
RemotingConfiguration.RegisterWellKnownServiceType(
|
||
|
typeof(SecretStore),
|
||
|
"getSecret(string id)",
|
||
|
WellKnownObjectMode.SingleCall );
|
||
|
|
||
|
System.Console.WriteLine("Server Started on "+ iPort);
|
||
|
// System.Console.ReadLine();
|
||
|
//return 0;
|
||
|
}
|
||
|
|
||
|
public void stopServer()
|
||
|
{
|
||
|
if (channel != null)
|
||
|
{
|
||
|
System.Console.WriteLine("Stopping server");
|
||
|
ChannelServices.UnregisterChannel(channel);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|