Refactored to only having one executor per platform
This commit is contained in:
@ -6,22 +6,47 @@ namespace Aurora.Backend.Executors
|
||||
{
|
||||
public abstract class BaseExecutor
|
||||
{
|
||||
public BaseExecutor()
|
||||
protected BaseExecutor()
|
||||
{
|
||||
}
|
||||
|
||||
public ExecutorType ExecutorType { get; protected set; }
|
||||
public Type ExecutorType { get; protected set; }
|
||||
|
||||
public static BaseExecutor CreateExecutor<T>(ExecutorType executorType) where T : BaseExecutor
|
||||
public static BaseExecutor CreateExecutor<T>()
|
||||
{
|
||||
MethodInfo method = typeof(T).GetMethod("Create");
|
||||
if (method == null)
|
||||
|
||||
BaseExecutor executor = null;
|
||||
if (typeof(T) == typeof(HostExecutor))
|
||||
{
|
||||
throw new InvalidOperationException("Executor must include a 'create' method.");
|
||||
executor = new HostExecutor();
|
||||
executor.ExecutorType = typeof(HostExecutor);
|
||||
}
|
||||
else if (typeof(T) == typeof(ClientExecutor))
|
||||
{
|
||||
executor = new ClientExecutor();
|
||||
executor.ExecutorType = typeof(ClientExecutor);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Cannot create an executor of type: " + nameof(T));
|
||||
}
|
||||
|
||||
return method.Invoke(null, new object[] { executorType }) as BaseExecutor;
|
||||
return executor;
|
||||
}
|
||||
|
||||
public abstract void Initialize();
|
||||
|
||||
public abstract void Run();
|
||||
|
||||
public abstract void Close();
|
||||
|
||||
public abstract void GetMembers();
|
||||
|
||||
public abstract void GetQueue();
|
||||
|
||||
public abstract void AddToQueue();
|
||||
|
||||
public abstract void RemoveFromQueue();
|
||||
}
|
||||
|
||||
public enum ExecutorType
|
||||
|
@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using Aurora.Backend.Server.Party;
|
||||
using Aurora.Backend.Client.Party;
|
||||
|
||||
namespace Aurora.Backend.Executors
|
||||
{
|
||||
public abstract class BasePartyExecutor : BaseExecutor
|
||||
{
|
||||
public BasePartyExecutor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static BasePartyExecutor Create(ExecutorType type)
|
||||
{
|
||||
BasePartyExecutor executor = null;
|
||||
switch (type)
|
||||
{
|
||||
case ExecutorType.Client:
|
||||
{
|
||||
executor = new ClientPartyExecutor();
|
||||
executor.ExecutorType = type;
|
||||
break;
|
||||
}
|
||||
case ExecutorType.Server:
|
||||
{
|
||||
executor = new HostPartyExecutor();
|
||||
executor.ExecutorType = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return executor;
|
||||
}
|
||||
|
||||
public abstract void Initialize();
|
||||
|
||||
public abstract void Run();
|
||||
|
||||
public abstract void Close();
|
||||
|
||||
public abstract void GetMembers();
|
||||
|
||||
public abstract void GetQueue();
|
||||
|
||||
public abstract void AddToQueue();
|
||||
|
||||
public abstract void RemoveFromQueue();
|
||||
|
||||
}
|
||||
}
|
48
Aurora/Backend/Executors/ClientExecutor.cs
Normal file
48
Aurora/Backend/Executors/ClientExecutor.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using Aurora.Backend.Executors;
|
||||
|
||||
namespace Aurora.Backend.Executors
|
||||
{
|
||||
public class ClientExecutor : BaseExecutor
|
||||
{
|
||||
public ClientExecutor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void AddToQueue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void GetMembers()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void GetQueue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void RemoveFromQueue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
57
Aurora/Backend/Executors/HostExecutor.cs
Normal file
57
Aurora/Backend/Executors/HostExecutor.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Aurora.Backend.Executors;
|
||||
using Aurora.Backend.Services;
|
||||
using Aurora.Backend.Proto;
|
||||
using Aurora.Backend.RemoteImpl;
|
||||
|
||||
namespace Aurora.Backend.Executors
|
||||
{
|
||||
public class HostExecutor : BaseExecutor
|
||||
{
|
||||
RemotePartyServiceImpl _remoteServiceImpl;
|
||||
RemotePlaybackServiceImpl _remotePlaybackImpl;
|
||||
public HostExecutor()
|
||||
{
|
||||
_remoteServiceImpl = new RemotePartyServiceImpl();
|
||||
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
//Register grpc RemoteService with singleton server service
|
||||
ServerService.Instance.RegisterService(RemotePartyService.BindService(_remoteServiceImpl));
|
||||
ServerService.Instance.RegisterService(RemotePlaybackService.BindService(_remotePlaybackImpl));
|
||||
}
|
||||
|
||||
public override async void Close()
|
||||
{
|
||||
await ServerService.Instance.Stop();
|
||||
}
|
||||
|
||||
public override void AddToQueue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void GetMembers()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void GetQueue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void RemoveFromQueue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user