Beginning stages for party executors
This commit is contained in:
@ -1,10 +0,0 @@
|
||||
using System;
|
||||
using Aurora.Backend.Proto;
|
||||
|
||||
namespace Aurora.Backend.Services.Server
|
||||
{
|
||||
class PartyServiceImpl : PartyService.PartyServiceBase
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
using System;
|
||||
using Aurora.Backend.Proto;
|
||||
|
||||
namespace Aurora.Backend.Services.Server
|
||||
{
|
||||
class PlaybackServiceImpl : PlaybackService.PlaybackServiceBase
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
57
Aurora/Backend/Services/ServerService.cs
Normal file
57
Aurora/Backend/Services/ServerService.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user