You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel.Discovery/DiscoveryService.cs

51 lines
1.4 KiB

using System.Collections.Generic;
using ZeroLevel.Models;
using ZeroLevel.Network;
using ZeroLevel.Services.Applications;
namespace ZeroLevel.Discovery
{
public sealed class DiscoveryService
: BaseWindowsService, IZeroService
{
private IExService _exInbox;
public DiscoveryService()
: base("Discovery")
{
}
public override void DisposeResources()
{
}
public override void PauseAction()
{
}
public override void ResumeAction()
{
}
public override void StartAction()
{
var routeTable = new RouteTable();
Injector.Default.Register<RouteTable>(routeTable);
var port = Configuration.Default.First<int>("apiport");
Startup.StartWebPanel(port, false);
var socketPort = Configuration.Default.First<int>("socketport");
_exInbox = ExchangeTransportFactory.GetServer("socket", socketPort);
_exInbox.RegisterInbox<IEnumerable<ServiceEndpointsInfo>>("services", (_, __) => routeTable.Get());
_exInbox.RegisterInbox<ExServiceInfo, InvokeResult>("register", (info, _, __) => routeTable.Append(info));
Log.Info($"TCP server started {_exInbox.Endpoint.Address}:{socketPort}");
}
public override void StopAction()
{
_exInbox.Dispose();
}
}
}

Powered by TurnKey Linux.