diff --git a/Aurora/Design/Components/MemberList/MemberList.xaml b/Aurora/Design/Components/MemberList/MemberList.xaml
index 07f37f1..ba3e38d 100644
--- a/Aurora/Design/Components/MemberList/MemberList.xaml
+++ b/Aurora/Design/Components/MemberList/MemberList.xaml
@@ -14,7 +14,7 @@
+ Text="{Binding Username}"/>
diff --git a/Aurora/Design/Components/MemberList/MemberList.xaml.cs b/Aurora/Design/Components/MemberList/MemberList.xaml.cs
index c393e15..41cf953 100644
--- a/Aurora/Design/Components/MemberList/MemberList.xaml.cs
+++ b/Aurora/Design/Components/MemberList/MemberList.xaml.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using Xamarin.Forms;
using Aurora.Design.Components.HorizontalList;
+using Aurora.Models;
namespace Aurora.Design.Components.MemberList
{
@@ -21,7 +22,7 @@ namespace Aurora.Design.Components.MemberList
///
public static readonly BindableProperty MembersProperty =
BindableProperty.Create(propertyName: "Members",
- returnType: typeof(IEnumerable),
+ returnType: typeof(IEnumerable),
declaringType: typeof(MemberList),
defaultBindingMode: BindingMode.Default,
propertyChanged: OnMembersChanged);
@@ -30,11 +31,11 @@ namespace Aurora.Design.Components.MemberList
/// Backing property for MembersProperty
///
///
- public IEnumerable Members
+ public IEnumerable Members
{
get
{
- return (IEnumerable)GetValue(MembersProperty);
+ return (IEnumerable)GetValue(MembersProperty);
}
set
{
@@ -54,7 +55,7 @@ namespace Aurora.Design.Components.MemberList
var membersList = control.FindByName("MembersHorizontalList") as HorizontalList.HorizontalList;
if (membersList != null)
{
- membersList.ItemsSource = newValue as IEnumerable;
+ membersList.ItemsSource = newValue as IEnumerable;
}
}
}
diff --git a/Aurora/Design/Views/Party/PartyViewModel.cs b/Aurora/Design/Views/Party/PartyViewModel.cs
index d7a8617..ac27686 100644
--- a/Aurora/Design/Views/Party/PartyViewModel.cs
+++ b/Aurora/Design/Views/Party/PartyViewModel.cs
@@ -3,6 +3,7 @@ using System.Collections.ObjectModel;
using Aurora.Executors;
using Aurora.Design.Components.HostSelector;
using Aurora.Services;
+using Aurora.Models;
using Xamarin.Forms;
namespace Aurora.Design.Views.Party
@@ -16,8 +17,6 @@ namespace Aurora.Design.Views.Party
public class PartyViewModel : BaseViewModel
{
- private ObservableCollection _members;
-
private PartyState _state;
private BaseExecutor _executor;
@@ -26,32 +25,25 @@ namespace Aurora.Design.Views.Party
private string _port;
+ private ObservableCollection _members;
+
public PartyViewModel()
{
- _members = new ObservableCollection()
- {
- "Kevin",
- "Brandon",
- "Sheila",
- "Dale",
- "Austin",
- "Tori",
- "Ashley",
- "Spencer",
- };
- OnPropertyChanged("Members");
-
this.JoinCommand = new Command(OnJoinExecute, CanJoinExecute);
this.HostCommand = new Command(OnHostExecute, CanHostExecute);
+ _members = new ObservableCollection();
State(PartyState.SelectingHost);
}
#region Properties
- public ObservableCollection Members
+ public ObservableCollection Members
{
- get { return _members; }
+ get
+ {
+ return _members;
+ }
set { SetProperty(ref _members, value); }
}
@@ -87,6 +79,7 @@ namespace Aurora.Design.Views.Party
{
_state = state;
OnPropertyChanged("IsSelectingHost");
+ OnPropertyChanged("IsNotSelectingHost");
}
#region Commands
@@ -117,6 +110,13 @@ namespace Aurora.Design.Views.Party
ServerService.Instance.Start();
+ _members = _executor.PartyMembers;
+ OnPropertyChanged("Members");
+ _executor.PartyMembers.CollectionChanged += (sender, e) =>
+ {
+ OnPropertyChanged("Members");
+ };
+
//Change state
State(PartyState.Connecting);
}
diff --git a/Aurora/Executors/BaseExecutor.cs b/Aurora/Executors/BaseExecutor.cs
index 78f4340..c9be024 100644
--- a/Aurora/Executors/BaseExecutor.cs
+++ b/Aurora/Executors/BaseExecutor.cs
@@ -1,6 +1,8 @@
using System;
using System.Reflection;
using System.Linq;
+using System.Collections.ObjectModel;
+using Aurora.Models;
namespace Aurora.Executors
{
@@ -12,6 +14,8 @@ namespace Aurora.Executors
public Type ExecutorType { get; protected set; }
+ public abstract ObservableCollection PartyMembers { get; }
+
public static BaseExecutor CreateExecutor()
{
@@ -40,7 +44,7 @@ namespace Aurora.Executors
public abstract void Close();
- public abstract void GetMembers();
+ public abstract ObservableCollection GetMembers();
public abstract void GetQueue();
diff --git a/Aurora/Executors/ClientExecutor.cs b/Aurora/Executors/ClientExecutor.cs
index 8797e21..d599e88 100644
--- a/Aurora/Executors/ClientExecutor.cs
+++ b/Aurora/Executors/ClientExecutor.cs
@@ -1,4 +1,6 @@
using System;
+using System.Collections.ObjectModel;
+using Aurora.Models;
using Aurora.Executors;
namespace Aurora.Executors
@@ -10,6 +12,14 @@ namespace Aurora.Executors
}
+ #region Properties
+ public override ObservableCollection PartyMembers
+ {
+ get { return null; }
+ }
+
+ #endregion Properties
+
public override void AddToQueue()
{
throw new NotImplementedException();
@@ -20,7 +30,7 @@ namespace Aurora.Executors
throw new NotImplementedException();
}
- public override void GetMembers()
+ public override ObservableCollection GetMembers()
{
throw new NotImplementedException();
}
diff --git a/Aurora/Executors/HostExecutor.cs b/Aurora/Executors/HostExecutor.cs
index d3b3cd1..767124d 100644
--- a/Aurora/Executors/HostExecutor.cs
+++ b/Aurora/Executors/HostExecutor.cs
@@ -1,5 +1,7 @@
using System;
using System.Threading.Tasks;
+using System.Collections.ObjectModel;
+using Aurora.Models;
using Aurora.Executors;
using Aurora.Services;
using Aurora.Proto;
@@ -9,21 +11,29 @@ namespace Aurora.Executors
{
public class HostExecutor : BaseExecutor
{
- RemotePartyServiceImpl _remoteServiceImpl;
+ RemotePartyServiceImpl _remotePartyServiceImpl;
RemotePlaybackServiceImpl _remotePlaybackImpl;
public HostExecutor()
{
- _remoteServiceImpl = new RemotePartyServiceImpl();
+ _remotePartyServiceImpl = new RemotePartyServiceImpl();
_remotePlaybackImpl = new RemotePlaybackServiceImpl();
}
public override void Initialize()
{
//Register grpc RemoteService with singleton server service
- ServerService.Instance.RegisterService(RemotePartyService.BindService(_remoteServiceImpl));
+ ServerService.Instance.RegisterService(RemotePartyService.BindService(_remotePartyServiceImpl));
ServerService.Instance.RegisterService(RemotePlaybackService.BindService(_remotePlaybackImpl));
}
+ #region Properties
+ public override ObservableCollection PartyMembers
+ {
+ get { return _remotePartyServiceImpl.PartyMembers; }
+ }
+
+ #endregion Properties
+
public override async void Close()
{
await ServerService.Instance.Stop();
@@ -34,7 +44,7 @@ namespace Aurora.Executors
throw new NotImplementedException();
}
- public override void GetMembers()
+ public override ObservableCollection GetMembers()
{
throw new NotImplementedException();
}
diff --git a/Aurora/RemoteImpl/RemotePartyImpl.cs b/Aurora/RemoteImpl/RemotePartyImpl.cs
index 5c98b7a..cba3087 100644
--- a/Aurora/RemoteImpl/RemotePartyImpl.cs
+++ b/Aurora/RemoteImpl/RemotePartyImpl.cs
@@ -1,6 +1,7 @@
using System;
using System.Threading.Tasks;
-using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
using Aurora.Proto;
using Aurora.Models;
using Aurora.Services;
@@ -12,14 +13,14 @@ namespace Aurora.RemoteImpl
///
/// Dictionary of party members. Key -> ClientId
///
- private Dictionary _partyMembers;
+ private ObservableCollection _partyMembers;
public RemotePartyServiceImpl()
{
- _partyMembers = new Dictionary();
+ _partyMembers = new ObservableCollection();
//Add self to members list
- _partyMembers.Add(SettingsService.Instance.Username, new PartyMember
+ _partyMembers.Add(new PartyMember
{
Username = SettingsService.Instance.Username,
Id = "asdf",
@@ -28,7 +29,7 @@ namespace Aurora.RemoteImpl
});
}
- public Dictionary PartyMembers
+ public ObservableCollection PartyMembers
{
get
{
@@ -38,7 +39,7 @@ namespace Aurora.RemoteImpl
public override Task JoinParty(JoinPartyRequest request, Grpc.Core.ServerCallContext context)
{
- _partyMembers.Add(request.ClientId, new PartyMember()
+ _partyMembers.Add(new PartyMember()
{
Username = request.UserName,
Id = request.ClientId,
@@ -52,7 +53,7 @@ namespace Aurora.RemoteImpl
public override Task LeaveParty(LeavePartyRequest request, Grpc.Core.ServerCallContext context)
{
- _partyMembers.Remove(request.ClientId);
+ _partyMembers.Remove(_partyMembers.Where(e => e.Id == request.ClientId).Single());
LeavePartyResponse response = new LeavePartyResponse() { Status = PartyJoinedStatusEnum.Disconnected };
return Task.FromResult(response);
}