Members now appearing on host
This commit is contained in:
parent
b18abf0400
commit
0d64c0732e
@ -14,7 +14,7 @@
|
||||
<DataTemplate>
|
||||
<Frame>
|
||||
<Label
|
||||
Text="{Binding .}"/>
|
||||
Text="{Binding Username}"/>
|
||||
</Frame>
|
||||
</DataTemplate>
|
||||
</hl:HorizontalList.ItemTemplate>
|
||||
|
@ -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
|
||||
/// <returns></returns>
|
||||
public static readonly BindableProperty MembersProperty =
|
||||
BindableProperty.Create(propertyName: "Members",
|
||||
returnType: typeof(IEnumerable<string>),
|
||||
returnType: typeof(IEnumerable<PartyMember>),
|
||||
declaringType: typeof(MemberList),
|
||||
defaultBindingMode: BindingMode.Default,
|
||||
propertyChanged: OnMembersChanged);
|
||||
@ -30,11 +31,11 @@ namespace Aurora.Design.Components.MemberList
|
||||
/// Backing property for MembersProperty
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public IEnumerable<string> Members
|
||||
public IEnumerable<PartyMember> Members
|
||||
{
|
||||
get
|
||||
{
|
||||
return (IEnumerable<string>)GetValue(MembersProperty);
|
||||
return (IEnumerable<PartyMember>)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<string>;
|
||||
membersList.ItemsSource = newValue as IEnumerable<PartyMember>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<string> _members;
|
||||
|
||||
private PartyState _state;
|
||||
|
||||
private BaseExecutor _executor;
|
||||
@ -26,32 +25,25 @@ namespace Aurora.Design.Views.Party
|
||||
|
||||
private string _port;
|
||||
|
||||
private ObservableCollection<PartyMember> _members;
|
||||
|
||||
|
||||
public PartyViewModel()
|
||||
{
|
||||
_members = new ObservableCollection<string>()
|
||||
{
|
||||
"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<PartyMember>();
|
||||
|
||||
State(PartyState.SelectingHost);
|
||||
}
|
||||
#region Properties
|
||||
|
||||
public ObservableCollection<string> Members
|
||||
public ObservableCollection<PartyMember> 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);
|
||||
}
|
||||
|
@ -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<PartyMember> PartyMembers { get; }
|
||||
|
||||
public static BaseExecutor CreateExecutor<T>()
|
||||
{
|
||||
|
||||
@ -40,7 +44,7 @@ namespace Aurora.Executors
|
||||
|
||||
public abstract void Close();
|
||||
|
||||
public abstract void GetMembers();
|
||||
public abstract ObservableCollection<PartyMember> GetMembers();
|
||||
|
||||
public abstract void GetQueue();
|
||||
|
||||
|
@ -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<PartyMember> 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<PartyMember> GetMembers()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -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<PartyMember> 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<PartyMember> GetMembers()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -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
|
||||
/// <summary>
|
||||
/// Dictionary of party members. Key -> ClientId
|
||||
/// </summary>
|
||||
private Dictionary<string, PartyMember> _partyMembers;
|
||||
private ObservableCollection<PartyMember> _partyMembers;
|
||||
|
||||
public RemotePartyServiceImpl()
|
||||
{
|
||||
_partyMembers = new Dictionary<string, PartyMember>();
|
||||
_partyMembers = new ObservableCollection<PartyMember>();
|
||||
|
||||
//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<string, PartyMember> PartyMembers
|
||||
public ObservableCollection<PartyMember> PartyMembers
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -38,7 +39,7 @@ namespace Aurora.RemoteImpl
|
||||
|
||||
public override Task<JoinPartyResponse> 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<LeavePartyResponse> 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user