Beginning stages for party executors

This commit is contained in:
watsonb8
2019-06-03 10:57:05 -04:00
parent 6503d2c410
commit b0307cf7b3
10 changed files with 370 additions and 39 deletions

View File

@ -1,10 +0,0 @@
using System;
using Aurora.Backend.Proto;
namespace Aurora.Backend.Services.Server
{
class PartyServiceImpl : PartyService.PartyServiceBase
{
}
}

View File

@ -1,10 +0,0 @@
using System;
using Aurora.Backend.Proto;
namespace Aurora.Backend.Services.Server
{
class PlaybackServiceImpl : PlaybackService.PlaybackServiceBase
{
}
}

View File

@ -1,28 +0,0 @@
using System;
using Grpc.Core;
using Aurora.Backend.Proto;
namespace Aurora.Backend.Services.Server
{
public class ServerService : BaseService<ServerService>
{
const int Port = 50051;
public ServerService()
{
Grpc.Core.Server server = new Grpc.Core.Server
{
Services = {
PartyService.BindService(new PartyServiceImpl()),
PlaybackService.BindService(new PlaybackServiceImpl()) },
Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
};
server.Start();
Console.WriteLine("Aurora server listening on port " + Port);
Console.WriteLine("Press any key to stop the server...");
Console.ReadKey();
server.ShutdownAsync().Wait();
}
}
}

View File

@ -0,0 +1,57 @@
using System;
using System.Threading.Tasks;
using Grpc.Core;
using Aurora.Backend.Proto;
namespace Aurora.Backend.Services
{
public class ServerService : BaseService<ServerService>
{
private const int Port = 50051;
private Grpc.Core.Server _server;
/// <summary>
/// Constructor. Registers GRPC service implementations.
/// </summary>
public ServerService()
{
_server = new Grpc.Core.Server
{
Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
};
Start();
}
/// <summary>
/// Start Server
/// </summary>
public void Start()
{
_server.Start();
}
/// <summary>
/// Shutdown server async.
/// </summary>
/// <returns>Task</returns>
public async Task Stop()
{
await _server.ShutdownAsync();
}
public async Task Reset()
{
await Stop();
_server = new Grpc.Core.Server
{
Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
};
}
public void RegisterService(ServerServiceDefinition definition)
{
_server.Services.Add(definition);
}
}
}