Adding dependency injection
This commit is contained in:
@ -8,11 +8,12 @@ using Aurora.Proto.Playback;
|
||||
using Aurora.Proto.Sync;
|
||||
using Aurora.Services.ClientService.Events;
|
||||
using System.Collections.Generic;
|
||||
using Aurora.Services.Settings;
|
||||
|
||||
namespace Aurora.Services.ClientService
|
||||
{
|
||||
|
||||
public class ClientService : BaseService<ClientService>
|
||||
public class ClientService : IClientService
|
||||
{
|
||||
private RemotePartyService.RemotePartyServiceClient _remotePartyClient;
|
||||
private RemoteEventService.RemoteEventServiceClient _remoteEventsClient;
|
||||
@ -20,17 +21,19 @@ namespace Aurora.Services.ClientService
|
||||
private RemoteSyncService.RemoteSyncServiceClient _remoteSyncClient;
|
||||
|
||||
private Channel _channel;
|
||||
CancellationTokenSource _eventCancellationTokenSource;
|
||||
private CancellationTokenSource _eventCancellationTokenSource;
|
||||
private ISettingsService _settingsService;
|
||||
|
||||
public ClientService()
|
||||
public ClientService(ISettingsService settingsService)
|
||||
{
|
||||
this._settingsService = settingsService;
|
||||
}
|
||||
|
||||
public MediaPausedEventHandler OnMediaPaused;
|
||||
public NewMediaPlayingEventHandler OnNewMediaPlaying;
|
||||
public PartyMemberJoinedEventHandler OnPartyMemberJoined;
|
||||
public PartyMemberLeftEventHandler OnPartyMemberLeft;
|
||||
public MediaResumedEventHandler OnMediaResumed;
|
||||
public MediaPausedEventHandler OnMediaPaused { get; set; }
|
||||
public NewMediaPlayingEventHandler OnNewMediaPlaying { get; set; }
|
||||
public PartyMemberJoinedEventHandler OnPartyMemberJoined { get; set; }
|
||||
public PartyMemberLeftEventHandler OnPartyMemberLeft { get; set; }
|
||||
public MediaResumedEventHandler OnMediaResumed { get; set; }
|
||||
|
||||
public RemotePartyService.RemotePartyServiceClient RemotePartyClient
|
||||
{
|
||||
@ -94,10 +97,10 @@ namespace Aurora.Services.ClientService
|
||||
public async Task GetEvents()
|
||||
{
|
||||
_eventCancellationTokenSource = new CancellationTokenSource();
|
||||
string clientId = SettingsService.Instance.ClientId;
|
||||
string clientId = this._settingsService.ClientId;
|
||||
Console.WriteLine(string.Format("CLIENT {0} - GetEvents called from client with id", clientId));
|
||||
using (AsyncServerStreamingCall<BaseEvent> eventStream = _remoteEventsClient
|
||||
.GetEvents(new EventsRequest { ClientId = SettingsService.Instance.ClientId }))
|
||||
.GetEvents(new EventsRequest { ClientId = this._settingsService.ClientId }))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
42
Aurora/Services/ClientService/IClientService.cs
Normal file
42
Aurora/Services/ClientService/IClientService.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using Aurora.Services.ClientService.Events;
|
||||
using Aurora.Proto.Events;
|
||||
using Aurora.Proto.Party;
|
||||
using Aurora.Proto.Playback;
|
||||
using Aurora.Proto.Sync;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Aurora.Services.ClientService
|
||||
{
|
||||
public interface IClientService
|
||||
{
|
||||
MediaPausedEventHandler OnMediaPaused { get; set; }
|
||||
NewMediaPlayingEventHandler OnNewMediaPlaying { get; set; }
|
||||
PartyMemberJoinedEventHandler OnPartyMemberJoined { get; set; }
|
||||
PartyMemberLeftEventHandler OnPartyMemberLeft { get; set; }
|
||||
MediaResumedEventHandler OnMediaResumed { get; set; }
|
||||
|
||||
RemotePartyService.RemotePartyServiceClient RemotePartyClient { get; }
|
||||
|
||||
RemoteEventService.RemoteEventServiceClient RemoteEventClient { get; }
|
||||
|
||||
RemotePlaybackService.RemotePlaybackServiceClient RemotePlaybackClient { get; }
|
||||
|
||||
RemoteSyncService.RemoteSyncServiceClient RemoteSyncClient { get; }
|
||||
|
||||
bool IsStarted { get; }
|
||||
|
||||
bool IsHost { get; set; }
|
||||
|
||||
void Start(string hostname, string port);
|
||||
|
||||
void Close();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronous function for processing events off of the event stream.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task GetEvents();
|
||||
|
||||
void StopEvents();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user