diff --git a/Aurora.test/ControllerTests/EventTests.cs b/Aurora.test/ControllerTests/EventTests.cs
index 16fba6f..513331c 100644
--- a/Aurora.test/ControllerTests/EventTests.cs
+++ b/Aurora.test/ControllerTests/EventTests.cs
@@ -1,8 +1,8 @@
using NUnit.Framework;
-using Aurora.Proto.PartyV2;
+using Aurora.Proto.Party;
using Aurora.Services.Server;
-using Aurora.Services.Server.EventManager;
+using Aurora.Services.EventManager;
using Grpc.Core;
using System.Threading.Tasks;
using System.Threading;
diff --git a/Aurora.test/ControllerTests/MediaControllerTest.cs b/Aurora.test/ControllerTests/MediaControllerTest.cs
index 9819313..cf9e4ba 100644
--- a/Aurora.test/ControllerTests/MediaControllerTest.cs
+++ b/Aurora.test/ControllerTests/MediaControllerTest.cs
@@ -1,5 +1,5 @@
using NUnit.Framework;
-using Aurora.Proto.PartyV2;
+using Aurora.Proto.Party;
using Aurora.Services.Server;
using Grpc.Core;
using System.Threading.Tasks;
diff --git a/Aurora.test/ControllerTests/MembersControllerTest.cs b/Aurora.test/ControllerTests/MembersControllerTest.cs
index a12111f..212ffc2 100644
--- a/Aurora.test/ControllerTests/MembersControllerTest.cs
+++ b/Aurora.test/ControllerTests/MembersControllerTest.cs
@@ -1,5 +1,5 @@
using NUnit.Framework;
-using Aurora.Proto.PartyV2;
+using Aurora.Proto.Party;
using Aurora.Services.Server;
using Grpc.Core;
using System.Threading.Tasks;
diff --git a/Aurora.test/ControllerTests/PartyControllerTest.cs b/Aurora.test/ControllerTests/PartyControllerTest.cs
index a08cda5..9c10b8d 100644
--- a/Aurora.test/ControllerTests/PartyControllerTest.cs
+++ b/Aurora.test/ControllerTests/PartyControllerTest.cs
@@ -1,6 +1,6 @@
using System.Threading.Tasks;
using NUnit.Framework;
-using Aurora.Proto.PartyV2;
+using Aurora.Proto.Party;
using Aurora.Services.Server;
using Grpc.Core;
using Autofac;
diff --git a/Aurora.test/ControllerTests/Setup.cs b/Aurora.test/ControllerTests/Setup.cs
index 46d53c8..f011bf7 100644
--- a/Aurora.test/ControllerTests/Setup.cs
+++ b/Aurora.test/ControllerTests/Setup.cs
@@ -1,9 +1,9 @@
using Autofac;
-using Aurora.Proto.PartyV2;
+using Aurora.Proto.Party;
using Aurora.Services.Server;
using Aurora.Services.Library;
using Aurora.Services.Settings;
-using Aurora.Services.Server.EventManager;
+using Aurora.Services.EventManager;
using Aurora.test.Models.Mock;
using System.IO;
using Grpc.Core;
diff --git a/Aurora.test/Models/Mock/SettingsServiceMock.cs b/Aurora.test/Models/Mock/SettingsServiceMock.cs
index bcc3c08..6126c92 100644
--- a/Aurora.test/Models/Mock/SettingsServiceMock.cs
+++ b/Aurora.test/Models/Mock/SettingsServiceMock.cs
@@ -28,7 +28,7 @@ namespace Aurora.test.Models.Mock
/// The current sessions clientId. This is assigned by the server. This is not persisted.
///
///
- public string ClientId { get; set; }
+ public string ClientName { get; set; }
public string LibraryLocation { get; set; }
}
diff --git a/Aurora/App.xaml.cs b/Aurora/App.xaml.cs
index b38d816..47ce0e9 100644
--- a/Aurora/App.xaml.cs
+++ b/Aurora/App.xaml.cs
@@ -6,8 +6,7 @@ using Aurora.Design.Views.Party;
using Aurora.Design.Views.Profile;
using Aurora.Design.Views.Songs;
using Aurora.Design.Views.Stations;
-using Aurora.Services.ClientService;
-using Aurora.Services.Server.EventManager;
+using Aurora.Services.EventManager;
using Autofac;
using LibVLCSharp.Shared;
using Xamarin.Forms;
@@ -30,7 +29,6 @@ namespace Aurora
// _builder.RegisterInstance(new PlayerService()).SingleInstance();
_builder.RegisterType().As().SingleInstance();
_builder.RegisterType().As().SingleInstance();
- _builder.RegisterType().As().SingleInstance();
_builder.RegisterType().As().SingleInstance();
_builder.RegisterType().As().SingleInstance();
_builder.RegisterType().SingleInstance();
diff --git a/Aurora/Aurora.csproj b/Aurora/Aurora.csproj
index 85cc85a..06593eb 100644
--- a/Aurora/Aurora.csproj
+++ b/Aurora/Aurora.csproj
@@ -62,10 +62,6 @@
-
-
-
-
diff --git a/Aurora/Design/Components/MemberList/MemberList.xaml.cs b/Aurora/Design/Components/MemberList/MemberList.xaml.cs
index 7a61fe4..0d09652 100644
--- a/Aurora/Design/Components/MemberList/MemberList.xaml.cs
+++ b/Aurora/Design/Components/MemberList/MemberList.xaml.cs
@@ -24,7 +24,7 @@ namespace Aurora.Design.Components.MemberList
///
public static readonly BindableProperty MembersProperty =
BindableProperty.Create(propertyName: "Members",
- returnType: typeof(ObservableCollection),
+ returnType: typeof(ObservableCollection),
declaringType: typeof(MemberList),
defaultBindingMode: BindingMode.Default,
propertyChanged: OnMembersChanged);
@@ -33,11 +33,11 @@ namespace Aurora.Design.Components.MemberList
/// Backing property for MembersProperty
///
///
- public ObservableCollection Members
+ public ObservableCollection Members
{
get
{
- return (ObservableCollection)GetValue(MembersProperty);
+ return (ObservableCollection)GetValue(MembersProperty);
}
set
{
diff --git a/Aurora/Design/Views/Party/PartyViewModel.cs b/Aurora/Design/Views/Party/PartyViewModel.cs
index be1e970..d775fa1 100644
--- a/Aurora/Design/Views/Party/PartyViewModel.cs
+++ b/Aurora/Design/Views/Party/PartyViewModel.cs
@@ -1,19 +1,18 @@
using System;
using System.Collections.ObjectModel;
+using System.Collections.Generic;
using System.Threading.Tasks;
+using System.Threading;
using System.Linq;
using Xamarin.Forms;
-using Aurora.Services;
-using Aurora.Proto.General;
using Aurora.Proto.Party;
-using Aurora.Proto.Events;
-using Aurora.Services.ClientService;
-using Aurora.Services.ClientService.Events;
-using Aurora.Services.Player;
-using Aurora.Services.EventManager;
using Aurora.Models.Media;
+using Aurora.Services.Client;
using Aurora.Design.Views.Party.NewPartyDialog;
using Aurora.Services.Settings;
+using Aurora.Services.Server;
+using Aurora.Services.EventManager;
+using Grpc.Core;
namespace Aurora.Design.Views.Party
{
@@ -25,25 +24,37 @@ namespace Aurora.Design.Views.Party
Hosting,
Connecting,
}
-
+ public delegate void EventHandler(BaseEvent e);
public class PartyViewModel : BaseViewModel
{
private PartyState _state;
private string _hostname = "";
- private ObservableCollection _members;
+ private ObservableCollection _members;
private ObservableCollection _queue;
private BaseMedia _selectedMedia;
- private IClientService _client;
+ // private IClientService _client;
private ISettingsService _settingsService;
+ private IClientService _clientService;
+ private IServerService _serverService;
+ private IEventManager _eventManager;
+
+ private CancellationTokenSource _eventCancellationTokenSource;
+
+ private Dictionary _eventHandlers;
private int _selectedTabIndex;
- public PartyViewModel(ISettingsService settingsService, IClientService clientService)
+ public PartyViewModel(
+ ISettingsService settingsService,
+ IServerService serverService,
+ IEventManager eventManager)
{
- _members = new ObservableCollection();
+ _members = new ObservableCollection();
_queue = new ObservableCollection();
this._settingsService = settingsService;
+ this._serverService = serverService;
+ this._eventManager = eventManager;
SetState(PartyState.SelectingHost);
@@ -51,19 +62,15 @@ namespace Aurora.Design.Views.Party
LeavePartyCommand = new Command(OnLeavePartyCommandExecute, CanLeavePartyCommandExecute);
- _client = clientService;
-
- _client.OnMediaPaused += this.OnRemoteMediaPaused;
- _client.OnMediaResumed += this.OnRemoteMediaResumed;
- _client.OnNewMediaPlaying += this.OnNewRemoteMediaPlaying;
- _client.OnPartyMemberJoined += this.OnPartyMemberJoined;
- _client.OnPartyMemberLeft += this.OnPartyMemberLeft;
-
- }
-
- ~PartyViewModel()
- {
- //Task.Run(ServerService.Instance.Stop);
+ //Setup event handlers
+ _eventHandlers = new Dictionary()
+ {
+ {BaseEvent.DerivedEventOneofCase.MediaPausedEvent, this.OnRemoteMediaPaused},
+ {BaseEvent.DerivedEventOneofCase.MediaResumedEvent, this.OnRemoteMediaResumed},
+ {BaseEvent.DerivedEventOneofCase.NewMediaPlayingEvent, this.OnNewRemoteMediaPlaying},
+ {BaseEvent.DerivedEventOneofCase.MemberCreatedEvent, this.OnPartyMemberJoined},
+ {BaseEvent.DerivedEventOneofCase.MemberDeletedEvent, this.OnPartyMemberLeft}
+ };
}
#region Properties
@@ -78,7 +85,7 @@ namespace Aurora.Design.Views.Party
/// Publc property for the members list
///
///
- public ObservableCollection Members
+ public ObservableCollection Members
{
get
{
@@ -140,7 +147,7 @@ namespace Aurora.Design.Views.Party
if (this._state == PartyState.Hosting ||
this._state == PartyState.InParty)
{
- await _client.GetEvents().ConfigureAwait(false);
+ await this.GetEvents().ConfigureAwait(false);
}
else
{
@@ -177,7 +184,7 @@ namespace Aurora.Design.Views.Party
///
public override Task OnInactive()
{
- _client.StopEvents();
+ this._eventCancellationTokenSource.Cancel();
return Task.FromResult