Compare commits
No commits in common. "feature/5-separate-party-viewmodel" and "master" have entirely different histories.
feature/5-
...
master
@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
namespace Aurora.Cursor
|
namespace Aurora.Cursor
|
||||||
{
|
{
|
||||||
public enum SortDirection
|
public enum SortDirection
|
||||||
@ -14,8 +15,8 @@ namespace Aurora.Cursor
|
|||||||
{
|
{
|
||||||
private CursorList<T> _list;
|
private CursorList<T> _list;
|
||||||
|
|
||||||
private string _previousPageToken;
|
private string? _previousPageToken;
|
||||||
private string _nextPageToken;
|
private string? _nextPageToken;
|
||||||
private int _pageSize;
|
private int _pageSize;
|
||||||
private Func<KeyValuePair<string, T>, string> _sortDelgate;
|
private Func<KeyValuePair<string, T>, string> _sortDelgate;
|
||||||
private SortDirection _direction;
|
private SortDirection _direction;
|
@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Aurora.Utils;
|
using Aurora.Utils;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
namespace Aurora.Cursor
|
namespace Aurora.Cursor
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -22,8 +23,12 @@ namespace Aurora.Cursor
|
|||||||
id = HashUtil.GetHash(new string[] { item.GetHashCode().ToString() }).ToString();
|
id = HashUtil.GetHash(new string[] { item.GetHashCode().ToString() }).ToString();
|
||||||
item.Id = id;
|
item.Id = id;
|
||||||
}
|
}
|
||||||
this.Add(id, item);
|
bool res = this.TryAdd(id, item);
|
||||||
|
|
||||||
|
if (res == false)
|
||||||
|
{
|
||||||
|
throw new System.Exception("Failed to add item to cursor list");
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
|||||||
|
namespace Aurora.Services.Signal
|
||||||
|
{
|
||||||
|
public partial class SignalService : Signal.SignalBase
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -105,14 +105,13 @@ message LeavePartyResponse {
|
|||||||
message Member {
|
message Member {
|
||||||
//Resource name of the party member to be returned (Added by server)
|
//Resource name of the party member to be returned (Added by server)
|
||||||
string name = 1;
|
string name = 1;
|
||||||
string id = 2;
|
string userName = 2;
|
||||||
string userName = 3;
|
|
||||||
|
|
||||||
//Added by server
|
//Added by server
|
||||||
string ipAddress = 4;
|
string ipAddress = 3;
|
||||||
|
|
||||||
//Added by server
|
//Added by server
|
||||||
google.protobuf.Timestamp addedOn = 5;
|
google.protobuf.Timestamp addedOn = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ListMembersRequest {
|
message ListMembersRequest {
|
||||||
|
351
aurora-shared/.gitignore
vendored
351
aurora-shared/.gitignore
vendored
@ -1,351 +0,0 @@
|
|||||||
## Ignore Visual Studio temporary files, build results, and
|
|
||||||
## files generated by popular Visual Studio add-ons.
|
|
||||||
##
|
|
||||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
|
||||||
|
|
||||||
# User-specific files
|
|
||||||
*.rsuser
|
|
||||||
*.suo
|
|
||||||
*.user
|
|
||||||
*.userosscache
|
|
||||||
*.sln.docstates
|
|
||||||
|
|
||||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
|
||||||
*.userprefs
|
|
||||||
|
|
||||||
# Mono auto generated files
|
|
||||||
mono_crash.*
|
|
||||||
|
|
||||||
# Build results
|
|
||||||
[Dd]ebug/
|
|
||||||
[Dd]ebugPublic/
|
|
||||||
[Rr]elease/
|
|
||||||
[Rr]eleases/
|
|
||||||
x64/
|
|
||||||
x86/
|
|
||||||
[Aa][Rr][Mm]/
|
|
||||||
[Aa][Rr][Mm]64/
|
|
||||||
bld/
|
|
||||||
[Bb]in/
|
|
||||||
[Oo]bj/
|
|
||||||
[Ll]og/
|
|
||||||
|
|
||||||
# Visual Studio 2015/2017 cache/options directory
|
|
||||||
.vs/
|
|
||||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
|
||||||
#wwwroot/
|
|
||||||
|
|
||||||
# Visual Studio 2017 auto generated files
|
|
||||||
Generated\ Files/
|
|
||||||
|
|
||||||
# MSTest test Results
|
|
||||||
[Tt]est[Rr]esult*/
|
|
||||||
[Bb]uild[Ll]og.*
|
|
||||||
|
|
||||||
# NUnit
|
|
||||||
*.VisualState.xml
|
|
||||||
TestResult.xml
|
|
||||||
nunit-*.xml
|
|
||||||
|
|
||||||
# Build Results of an ATL Project
|
|
||||||
[Dd]ebugPS/
|
|
||||||
[Rr]eleasePS/
|
|
||||||
dlldata.c
|
|
||||||
|
|
||||||
# Benchmark Results
|
|
||||||
BenchmarkDotNet.Artifacts/
|
|
||||||
|
|
||||||
# .NET Core
|
|
||||||
project.lock.json
|
|
||||||
project.fragment.lock.json
|
|
||||||
artifacts/
|
|
||||||
|
|
||||||
# StyleCop
|
|
||||||
StyleCopReport.xml
|
|
||||||
|
|
||||||
# Files built by Visual Studio
|
|
||||||
*_i.c
|
|
||||||
*_p.c
|
|
||||||
*_h.h
|
|
||||||
*.ilk
|
|
||||||
*.meta
|
|
||||||
*.obj
|
|
||||||
*.iobj
|
|
||||||
*.pch
|
|
||||||
*.pdb
|
|
||||||
*.ipdb
|
|
||||||
*.pgc
|
|
||||||
*.pgd
|
|
||||||
*.rsp
|
|
||||||
*.sbr
|
|
||||||
*.tlb
|
|
||||||
*.tli
|
|
||||||
*.tlh
|
|
||||||
*.tmp
|
|
||||||
*.tmp_proj
|
|
||||||
*_wpftmp.csproj
|
|
||||||
*.log
|
|
||||||
*.vspscc
|
|
||||||
*.vssscc
|
|
||||||
.builds
|
|
||||||
*.pidb
|
|
||||||
*.svclog
|
|
||||||
*.scc
|
|
||||||
|
|
||||||
# Chutzpah Test files
|
|
||||||
_Chutzpah*
|
|
||||||
|
|
||||||
# Visual C++ cache files
|
|
||||||
ipch/
|
|
||||||
*.aps
|
|
||||||
*.ncb
|
|
||||||
*.opendb
|
|
||||||
*.opensdf
|
|
||||||
*.sdf
|
|
||||||
*.cachefile
|
|
||||||
*.VC.db
|
|
||||||
*.VC.VC.opendb
|
|
||||||
|
|
||||||
# Visual Studio profiler
|
|
||||||
*.psess
|
|
||||||
*.vsp
|
|
||||||
*.vspx
|
|
||||||
*.sap
|
|
||||||
|
|
||||||
# Visual Studio Trace Files
|
|
||||||
*.e2e
|
|
||||||
|
|
||||||
# TFS 2012 Local Workspace
|
|
||||||
$tf/
|
|
||||||
|
|
||||||
# Guidance Automation Toolkit
|
|
||||||
*.gpState
|
|
||||||
|
|
||||||
# ReSharper is a .NET coding add-in
|
|
||||||
_ReSharper*/
|
|
||||||
*.[Rr]e[Ss]harper
|
|
||||||
*.DotSettings.user
|
|
||||||
|
|
||||||
# JustCode is a .NET coding add-in
|
|
||||||
.JustCode
|
|
||||||
|
|
||||||
# TeamCity is a build add-in
|
|
||||||
_TeamCity*
|
|
||||||
|
|
||||||
# DotCover is a Code Coverage Tool
|
|
||||||
*.dotCover
|
|
||||||
|
|
||||||
# AxoCover is a Code Coverage Tool
|
|
||||||
.axoCover/*
|
|
||||||
!.axoCover/settings.json
|
|
||||||
|
|
||||||
# Visual Studio code coverage results
|
|
||||||
*.coverage
|
|
||||||
*.coveragexml
|
|
||||||
|
|
||||||
# NCrunch
|
|
||||||
_NCrunch_*
|
|
||||||
.*crunch*.local.xml
|
|
||||||
nCrunchTemp_*
|
|
||||||
|
|
||||||
# MightyMoose
|
|
||||||
*.mm.*
|
|
||||||
AutoTest.Net/
|
|
||||||
|
|
||||||
# Web workbench (sass)
|
|
||||||
.sass-cache/
|
|
||||||
|
|
||||||
# Installshield output folder
|
|
||||||
[Ee]xpress/
|
|
||||||
|
|
||||||
# DocProject is a documentation generator add-in
|
|
||||||
DocProject/buildhelp/
|
|
||||||
DocProject/Help/*.HxT
|
|
||||||
DocProject/Help/*.HxC
|
|
||||||
DocProject/Help/*.hhc
|
|
||||||
DocProject/Help/*.hhk
|
|
||||||
DocProject/Help/*.hhp
|
|
||||||
DocProject/Help/Html2
|
|
||||||
DocProject/Help/html
|
|
||||||
|
|
||||||
# Click-Once directory
|
|
||||||
publish/
|
|
||||||
|
|
||||||
# Publish Web Output
|
|
||||||
*.[Pp]ublish.xml
|
|
||||||
*.azurePubxml
|
|
||||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
|
||||||
# but database connection strings (with potential passwords) will be unencrypted
|
|
||||||
*.pubxml
|
|
||||||
*.publishproj
|
|
||||||
|
|
||||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
|
||||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
|
||||||
# in these scripts will be unencrypted
|
|
||||||
PublishScripts/
|
|
||||||
|
|
||||||
# NuGet Packages
|
|
||||||
*.nupkg
|
|
||||||
# NuGet Symbol Packages
|
|
||||||
*.snupkg
|
|
||||||
# The packages folder can be ignored because of Package Restore
|
|
||||||
**/[Pp]ackages/*
|
|
||||||
# except build/, which is used as an MSBuild target.
|
|
||||||
!**/[Pp]ackages/build/
|
|
||||||
# Uncomment if necessary however generally it will be regenerated when needed
|
|
||||||
#!**/[Pp]ackages/repositories.config
|
|
||||||
# NuGet v3's project.json files produces more ignorable files
|
|
||||||
*.nuget.props
|
|
||||||
*.nuget.targets
|
|
||||||
|
|
||||||
# Microsoft Azure Build Output
|
|
||||||
csx/
|
|
||||||
*.build.csdef
|
|
||||||
|
|
||||||
# Microsoft Azure Emulator
|
|
||||||
ecf/
|
|
||||||
rcf/
|
|
||||||
|
|
||||||
# Windows Store app package directories and files
|
|
||||||
AppPackages/
|
|
||||||
BundleArtifacts/
|
|
||||||
Package.StoreAssociation.xml
|
|
||||||
_pkginfo.txt
|
|
||||||
*.appx
|
|
||||||
*.appxbundle
|
|
||||||
*.appxupload
|
|
||||||
|
|
||||||
# Visual Studio cache files
|
|
||||||
# files ending in .cache can be ignored
|
|
||||||
*.[Cc]ache
|
|
||||||
# but keep track of directories ending in .cache
|
|
||||||
!?*.[Cc]ache/
|
|
||||||
|
|
||||||
# Others
|
|
||||||
ClientBin/
|
|
||||||
~$*
|
|
||||||
*~
|
|
||||||
*.dbmdl
|
|
||||||
*.dbproj.schemaview
|
|
||||||
*.jfm
|
|
||||||
*.pfx
|
|
||||||
*.publishsettings
|
|
||||||
orleans.codegen.cs
|
|
||||||
|
|
||||||
# Including strong name files can present a security risk
|
|
||||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
|
||||||
#*.snk
|
|
||||||
|
|
||||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
|
||||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
|
||||||
#bower_components/
|
|
||||||
|
|
||||||
# RIA/Silverlight projects
|
|
||||||
Generated_Code/
|
|
||||||
|
|
||||||
# Backup & report files from converting an old project file
|
|
||||||
# to a newer Visual Studio version. Backup files are not needed,
|
|
||||||
# because we have git ;-)
|
|
||||||
_UpgradeReport_Files/
|
|
||||||
Backup*/
|
|
||||||
UpgradeLog*.XML
|
|
||||||
UpgradeLog*.htm
|
|
||||||
ServiceFabricBackup/
|
|
||||||
*.rptproj.bak
|
|
||||||
|
|
||||||
# SQL Server files
|
|
||||||
*.mdf
|
|
||||||
*.ldf
|
|
||||||
*.ndf
|
|
||||||
|
|
||||||
# Business Intelligence projects
|
|
||||||
*.rdl.data
|
|
||||||
*.bim.layout
|
|
||||||
*.bim_*.settings
|
|
||||||
*.rptproj.rsuser
|
|
||||||
*- [Bb]ackup.rdl
|
|
||||||
*- [Bb]ackup ([0-9]).rdl
|
|
||||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
|
||||||
|
|
||||||
# Microsoft Fakes
|
|
||||||
FakesAssemblies/
|
|
||||||
|
|
||||||
# GhostDoc plugin setting file
|
|
||||||
*.GhostDoc.xml
|
|
||||||
|
|
||||||
# Node.js Tools for Visual Studio
|
|
||||||
.ntvs_analysis.dat
|
|
||||||
node_modules/
|
|
||||||
|
|
||||||
# Visual Studio 6 build log
|
|
||||||
*.plg
|
|
||||||
|
|
||||||
# Visual Studio 6 workspace options file
|
|
||||||
*.opt
|
|
||||||
|
|
||||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
|
||||||
*.vbw
|
|
||||||
|
|
||||||
# Visual Studio LightSwitch build output
|
|
||||||
**/*.HTMLClient/GeneratedArtifacts
|
|
||||||
**/*.DesktopClient/GeneratedArtifacts
|
|
||||||
**/*.DesktopClient/ModelManifest.xml
|
|
||||||
**/*.Server/GeneratedArtifacts
|
|
||||||
**/*.Server/ModelManifest.xml
|
|
||||||
_Pvt_Extensions
|
|
||||||
|
|
||||||
# Paket dependency manager
|
|
||||||
.paket/paket.exe
|
|
||||||
paket-files/
|
|
||||||
|
|
||||||
# FAKE - F# Make
|
|
||||||
.fake/
|
|
||||||
|
|
||||||
# CodeRush personal settings
|
|
||||||
.cr/personal
|
|
||||||
|
|
||||||
# Python Tools for Visual Studio (PTVS)
|
|
||||||
__pycache__/
|
|
||||||
*.pyc
|
|
||||||
|
|
||||||
# Cake - Uncomment if you are using it
|
|
||||||
# tools/**
|
|
||||||
# !tools/packages.config
|
|
||||||
|
|
||||||
# Tabs Studio
|
|
||||||
*.tss
|
|
||||||
|
|
||||||
# Telerik's JustMock configuration file
|
|
||||||
*.jmconfig
|
|
||||||
|
|
||||||
# BizTalk build output
|
|
||||||
*.btp.cs
|
|
||||||
*.btm.cs
|
|
||||||
*.odx.cs
|
|
||||||
*.xsd.cs
|
|
||||||
|
|
||||||
# OpenCover UI analysis results
|
|
||||||
OpenCover/
|
|
||||||
|
|
||||||
# Azure Stream Analytics local run output
|
|
||||||
ASALocalRun/
|
|
||||||
|
|
||||||
# MSBuild Binary and Structured Log
|
|
||||||
*.binlog
|
|
||||||
|
|
||||||
# NVidia Nsight GPU debugger configuration file
|
|
||||||
*.nvuser
|
|
||||||
|
|
||||||
# MFractors (Xamarin productivity tool) working folder
|
|
||||||
.mfractor/
|
|
||||||
|
|
||||||
# Local History for Visual Studio
|
|
||||||
.localhistory/
|
|
||||||
|
|
||||||
# BeatPulse healthcheck temp database
|
|
||||||
healthchecksdb
|
|
||||||
|
|
||||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
|
||||||
MigrationBackup/
|
|
||||||
|
|
||||||
start*.sh
|
|
@ -1,8 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
|
||||||
<RootNamespace>aurora_shared</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -505,7 +505,6 @@
|
|||||||
<Project>{17F51282-39BE-4FE3-8EC7-6D108F5DD0FD}</Project>
|
<Project>{17F51282-39BE-4FE3-8EC7-6D108F5DD0FD}</Project>
|
||||||
<Name>Aurora</Name>
|
<Name>Aurora</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\..\aurora-shared\aurora-shared.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Resources\play.png">
|
<Content Include="Resources\play.png">
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Aurora\Aurora.csproj" />
|
<ProjectReference Include="..\Aurora\Aurora.csproj" />
|
||||||
<ProjectReference Include="..\..\aurora-shared\aurora-shared.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="Resources\Jidenna\The Chief\04 Bambi.mp3">
|
<None Update="Resources\Jidenna\The Chief\04 Bambi.mp3">
|
||||||
|
@ -7,7 +7,8 @@ using Aurora.Design.Views.Profile;
|
|||||||
using Aurora.Design.Views.Songs;
|
using Aurora.Design.Views.Songs;
|
||||||
using Aurora.Design.Views.Stations;
|
using Aurora.Design.Views.Stations;
|
||||||
using Aurora.Services.EventManager;
|
using Aurora.Services.EventManager;
|
||||||
using Aurora.Services;
|
using Aurora.Services.Server;
|
||||||
|
using Aurora.Services.Client;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using LibVLCSharp.Shared;
|
using LibVLCSharp.Shared;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
@ -27,19 +28,19 @@ namespace Aurora
|
|||||||
|
|
||||||
//Register DI
|
//Register DI
|
||||||
ContainerBuilder _builder = new ContainerBuilder();
|
ContainerBuilder _builder = new ContainerBuilder();
|
||||||
_builder.RegisterInstance<IPlayer>(new PlayerService()).SingleInstance();
|
// _builder.RegisterInstance<IPlayer>(new PlayerService()).SingleInstance();
|
||||||
_builder.RegisterType<Global>().As<Global>().SingleInstance();
|
|
||||||
_builder.RegisterType<PlayerService>().As<IPlayer>().SingleInstance();
|
_builder.RegisterType<PlayerService>().As<IPlayer>().SingleInstance();
|
||||||
_builder.RegisterType<SettingsService>().As<ISettingsService>().SingleInstance();
|
_builder.RegisterType<SettingsService>().As<ISettingsService>().SingleInstance();
|
||||||
_builder.RegisterType<LibraryService>().As<ILibraryService>().SingleInstance();
|
_builder.RegisterType<LibraryService>().As<ILibraryService>().SingleInstance();
|
||||||
_builder.RegisterType<EventManager>().As<IEventManager>().SingleInstance();
|
_builder.RegisterType<EventManager>().As<IEventManager>().SingleInstance();
|
||||||
|
_builder.RegisterType<ServerService>().As<IServerService>().SingleInstance();
|
||||||
|
_builder.RegisterType<ClientService>().As<IClientService>().SingleInstance();
|
||||||
_builder.RegisterType<MainView>().SingleInstance();
|
_builder.RegisterType<MainView>().SingleInstance();
|
||||||
_builder.RegisterType<AlbumsViewModel>();
|
_builder.RegisterType<AlbumsViewModel>();
|
||||||
_builder.RegisterType<ArtistsViewModel>();
|
_builder.RegisterType<ArtistsViewModel>();
|
||||||
_builder.RegisterType<PartyViewModel>();
|
_builder.RegisterType<PartyViewModel>();
|
||||||
_builder.RegisterType<ProfileViewModel>();
|
_builder.RegisterType<ProfileViewModel>();
|
||||||
_builder.RegisterType<SongsViewModel>();
|
_builder.RegisterType<SongsViewModel>();
|
||||||
_builder.RegisterType<HostPartyViewModel>();
|
|
||||||
_builder.RegisterType<StationsViewModel>();
|
_builder.RegisterType<StationsViewModel>();
|
||||||
|
|
||||||
// _builder.RegisterInstance<ISettingsService>(new SettingsService()).SingleInstance();
|
// _builder.RegisterInstance<ISettingsService>(new SettingsService()).SingleInstance();
|
||||||
|
@ -83,7 +83,4 @@
|
|||||||
<None Remove="Resources\like.png" />
|
<None Remove="Resources\like.png" />
|
||||||
<None Remove="Resources\play.png" />
|
<None Remove="Resources\play.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\..\aurora-shared\aurora-shared.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
@ -1,12 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using Aurora.Cursor;
|
|
||||||
|
|
||||||
namespace Aurora.Proto.Party
|
namespace Aurora.Proto.Party
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Partial PartyMember class with a constructor that generates a new id
|
/// Partial PartyMember class with a constructor that generates a new id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class Member : ICursorObject
|
public partial class Member
|
||||||
{
|
{
|
||||||
public Member(string id)
|
public Member(string id)
|
||||||
{
|
{
|
46
aurora-sharp-desktop/Aurora/Services/Client/ClientService.cs
Normal file
46
aurora-sharp-desktop/Aurora/Services/Client/ClientService.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
using Grpc.Core;
|
||||||
|
using Aurora.Proto.Party;
|
||||||
|
using Aurora.Services.Settings;
|
||||||
|
|
||||||
|
namespace Aurora.Services.Client
|
||||||
|
{
|
||||||
|
|
||||||
|
public class ClientService : IClientService
|
||||||
|
{
|
||||||
|
private RemotePartyService.RemotePartyServiceClient _remotePartyClient;
|
||||||
|
|
||||||
|
private Channel _channel;
|
||||||
|
private ISettingsService _settingsService;
|
||||||
|
|
||||||
|
public ClientService(ISettingsService settingsService)
|
||||||
|
{
|
||||||
|
this._settingsService = settingsService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsStarted
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _remotePartyClient != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public RemotePartyService.RemotePartyServiceClient RemotePartyServiceClient
|
||||||
|
{
|
||||||
|
get { return this._remotePartyClient; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Start(string hostname, string port)
|
||||||
|
{
|
||||||
|
_channel = new Channel(string.Format("{0}:{1}", hostname, port), ChannelCredentials.Insecure);
|
||||||
|
|
||||||
|
_remotePartyClient = new RemotePartyService.RemotePartyServiceClient(_channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void Close()
|
||||||
|
{
|
||||||
|
await _channel.ShutdownAsync();
|
||||||
|
_remotePartyClient = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using Aurora.Proto.Party;
|
||||||
|
|
||||||
|
namespace Aurora.Services.Client
|
||||||
|
{
|
||||||
|
public interface IClientService
|
||||||
|
{
|
||||||
|
bool IsStarted { get; }
|
||||||
|
|
||||||
|
RemotePartyService.RemotePartyServiceClient RemotePartyServiceClient { get; }
|
||||||
|
|
||||||
|
void Start(string hostname, string port);
|
||||||
|
|
||||||
|
void Close();
|
||||||
|
}
|
||||||
|
}
|
@ -1,19 +0,0 @@
|
|||||||
namespace Aurora.Services
|
|
||||||
{
|
|
||||||
public enum PartyState
|
|
||||||
{
|
|
||||||
Idle,
|
|
||||||
SelectingHost,
|
|
||||||
InParty,
|
|
||||||
Hosting,
|
|
||||||
Connecting,
|
|
||||||
}
|
|
||||||
public class Global
|
|
||||||
{
|
|
||||||
public Global()
|
|
||||||
{
|
|
||||||
this.State = PartyState.Idle;
|
|
||||||
}
|
|
||||||
public PartyState State {get; set;}
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,10 +6,9 @@ using Aurora.Services.Library;
|
|||||||
using Aurora.Services.Settings;
|
using Aurora.Services.Settings;
|
||||||
using Aurora.Models.Media;
|
using Aurora.Models.Media;
|
||||||
using Aurora.Services.EventManager;
|
using Aurora.Services.EventManager;
|
||||||
using Aurora.Utils;
|
using Autofac;
|
||||||
using Aurora.Cursor;
|
|
||||||
|
|
||||||
namespace Aurora.Services.Controllers
|
namespace Aurora.Services.Server.Controllers
|
||||||
{
|
{
|
||||||
public partial class RemotePartyController : RemotePartyService.RemotePartyServiceBase
|
public partial class RemotePartyController : RemotePartyService.RemotePartyServiceBase
|
||||||
{
|
{
|
||||||
@ -25,7 +24,7 @@ namespace Aurora.Services.Controllers
|
|||||||
this._startDateTime = DateTime.UtcNow;
|
this._startDateTime = DateTime.UtcNow;
|
||||||
this._displayName = partyName;
|
this._displayName = partyName;
|
||||||
this._description = description;
|
this._description = description;
|
||||||
this._memberList = new CursorList<Member>();
|
this._memberList = new SortedList<string, Member>();
|
||||||
this._mediaList = new SortedList<string, Media>();
|
this._mediaList = new SortedList<string, Media>();
|
||||||
|
|
||||||
_libraryService = libraryService;
|
_libraryService = libraryService;
|
||||||
@ -37,9 +36,9 @@ namespace Aurora.Services.Controllers
|
|||||||
|
|
||||||
this._hostMember = new Member()
|
this._hostMember = new Member()
|
||||||
{
|
{
|
||||||
Name = GetNewMemberResourceName(_partyResourceName, IpUtil.GetLocalIPAddress(), userName),
|
Name = GetNewMemberResourceName(_partyResourceName, ServerService.GetLocalIPAddress(), userName),
|
||||||
UserName = userName,
|
UserName = userName,
|
||||||
IpAddress = IpUtil.GetLocalIPAddress(),
|
IpAddress = ServerService.GetLocalIPAddress(),
|
||||||
};
|
};
|
||||||
|
|
||||||
//Add media from library
|
//Add media from library
|
@ -4,7 +4,7 @@ using System.Threading;
|
|||||||
using Aurora.Proto.Party;
|
using Aurora.Proto.Party;
|
||||||
using Aurora.Utils;
|
using Aurora.Utils;
|
||||||
|
|
||||||
namespace Aurora.Services.Controllers
|
namespace Aurora.Services.Server.Controllers
|
||||||
{
|
{
|
||||||
public partial class RemotePartyController : RemotePartyService.RemotePartyServiceBase
|
public partial class RemotePartyController : RemotePartyService.RemotePartyServiceBase
|
||||||
{
|
{
|
@ -5,7 +5,7 @@ using Aurora.Proto.Party;
|
|||||||
using Aurora.Proto.General;
|
using Aurora.Proto.General;
|
||||||
using Aurora.Utils;
|
using Aurora.Utils;
|
||||||
|
|
||||||
namespace Aurora.Services.Controllers
|
namespace Aurora.Services.Server.Controllers
|
||||||
{
|
{
|
||||||
public partial class RemotePartyController : RemotePartyService.RemotePartyServiceBase
|
public partial class RemotePartyController : RemotePartyService.RemotePartyServiceBase
|
||||||
{
|
{
|
@ -8,7 +8,7 @@ using Aurora.Services.Library;
|
|||||||
using Aurora.Services.Player;
|
using Aurora.Services.Player;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
|
|
||||||
namespace Aurora.Services.Controllers
|
namespace Aurora.Services.Server.Controllers
|
||||||
{
|
{
|
||||||
public partial class RemotePartyController : RemotePartyService.RemotePartyServiceBase
|
public partial class RemotePartyController : RemotePartyService.RemotePartyServiceBase
|
||||||
{
|
{
|
@ -6,50 +6,40 @@ using Aurora.Proto.General;
|
|||||||
using Aurora.Utils;
|
using Aurora.Utils;
|
||||||
using Grpc.Core;
|
using Grpc.Core;
|
||||||
using Google.Protobuf.WellKnownTypes;
|
using Google.Protobuf.WellKnownTypes;
|
||||||
using Aurora.Cursor;
|
|
||||||
|
|
||||||
namespace Aurora.Services.Controllers
|
namespace Aurora.Services.Server.Controllers
|
||||||
{
|
{
|
||||||
public partial class RemotePartyController : RemotePartyService.RemotePartyServiceBase
|
public partial class RemotePartyController : RemotePartyService.RemotePartyServiceBase
|
||||||
{
|
{
|
||||||
private CursorList<Member> _memberList;
|
private SortedList<string, Member> _memberList;
|
||||||
|
|
||||||
public CursorList<Member> MemberList
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return this._memberList;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if(this._memberList != value)
|
|
||||||
{
|
|
||||||
_memberList = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Task<ListMembersResponse> ListMembers(ListMembersRequest request, Grpc.Core.ServerCallContext context)
|
public override Task<ListMembersResponse> ListMembers(ListMembersRequest request, Grpc.Core.ServerCallContext context)
|
||||||
{
|
{
|
||||||
Cursor<Member> cursor = new Cursor<Member>(ref this._memberList);
|
|
||||||
|
|
||||||
Aurora.Cursor.SortDirection direction = Aurora.Cursor.SortDirection.Asc;
|
|
||||||
|
|
||||||
CursorResult<Member> res = cursor
|
|
||||||
.WithNextPageToken(request.PageToken)
|
|
||||||
.WithSize(request.PageSize)
|
|
||||||
.GetNextPage();
|
|
||||||
|
|
||||||
//Ignoring parent field because there is only one instance of the party
|
//Ignoring parent field because there is only one instance of the party
|
||||||
ListMembersResponse resp = new ListMembersResponse();
|
ListMembersResponse resp = new ListMembersResponse();
|
||||||
|
|
||||||
resp.Members.AddRange(res.Result.ConvertAll(member => new Member()
|
//Determine start idx
|
||||||
|
int startIdx = 0;
|
||||||
|
if (!string.IsNullOrEmpty(request.PageToken))
|
||||||
{
|
{
|
||||||
Name = member.Name,
|
startIdx = _memberList.IndexOfKey(request.PageToken) + 1;
|
||||||
UserName = member.UserName,
|
}
|
||||||
IpAddress = member.IpAddress,
|
|
||||||
AddedOn = member.AddedOn
|
int pageSize = request.PageSize;
|
||||||
}));
|
|
||||||
|
//Assign pageSize
|
||||||
|
if (pageSize > _memberList.Count)
|
||||||
|
{
|
||||||
|
pageSize = _memberList.Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Gather page
|
||||||
|
List<Member> members = new List<Member>(_memberList.Values);
|
||||||
|
resp.Members.AddRange(members.GetRange(startIdx, pageSize));
|
||||||
|
|
||||||
|
//Set next page token
|
||||||
|
resp.NextPageToken = resp.Members[resp.Members.Count - 1].Name;
|
||||||
|
|
||||||
return Task.FromResult(resp);
|
return Task.FromResult(resp);
|
||||||
}
|
}
|
||||||
@ -86,7 +76,7 @@ namespace Aurora.Services.Controllers
|
|||||||
request.Member.AddedOn = Timestamp.FromDateTime(DateTime.UtcNow);
|
request.Member.AddedOn = Timestamp.FromDateTime(DateTime.UtcNow);
|
||||||
request.Member.IpAddress = context.Host;
|
request.Member.IpAddress = context.Host;
|
||||||
|
|
||||||
_memberList.Add(request.Member);
|
_memberList.Add(resourceName, request.Member);
|
||||||
|
|
||||||
BaseEvent @event = new BaseEvent
|
BaseEvent @event = new BaseEvent
|
||||||
{
|
{
|
@ -1,11 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Aurora.Utils;
|
using System.Collections.Generic;
|
||||||
using Aurora.Proto.Party;
|
using Aurora.Proto.Party;
|
||||||
using Google.Protobuf.WellKnownTypes;
|
using Google.Protobuf.WellKnownTypes;
|
||||||
|
|
||||||
|
|
||||||
namespace Aurora.Services.Controllers
|
namespace Aurora.Services.Server.Controllers
|
||||||
{
|
{
|
||||||
public partial class RemotePartyController : RemotePartyService.RemotePartyServiceBase
|
public partial class RemotePartyController : RemotePartyService.RemotePartyServiceBase
|
||||||
{
|
{
|
||||||
@ -22,7 +22,7 @@ namespace Aurora.Services.Controllers
|
|||||||
Name = _partyResourceName,
|
Name = _partyResourceName,
|
||||||
DisplayName = this._displayName,
|
DisplayName = this._displayName,
|
||||||
Description = this._description,
|
Description = this._description,
|
||||||
HostIp = IpUtil.GetLocalIPAddress(),
|
HostIp = ServerService.GetLocalIPAddress(),
|
||||||
HostMember = this._hostMember,
|
HostMember = this._hostMember,
|
||||||
CreatedOn = Timestamp.FromDateTime(_startDateTime)
|
CreatedOn = Timestamp.FromDateTime(_startDateTime)
|
||||||
};
|
};
|
@ -0,0 +1,27 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Aurora.Services.Server
|
||||||
|
{
|
||||||
|
public interface IServerService
|
||||||
|
{
|
||||||
|
int Port { get; }
|
||||||
|
|
||||||
|
string Hostname { get; }
|
||||||
|
|
||||||
|
bool Initialized { get; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Start Server
|
||||||
|
/// </summary>
|
||||||
|
void Start(string partyName, string description);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shutdown server async.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Task</returns>
|
||||||
|
Task Stop();
|
||||||
|
|
||||||
|
Task Reset();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,144 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using Grpc.Core;
|
||||||
|
using Aurora.Services.Server.Controllers;
|
||||||
|
using Aurora.Services.Settings;
|
||||||
|
using Aurora.Services.Library;
|
||||||
|
using Aurora.Services.EventManager;
|
||||||
|
using Aurora.Proto.Party;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Aurora.Services.Server
|
||||||
|
{
|
||||||
|
public class ServerService : IServerService
|
||||||
|
{
|
||||||
|
private int _port = 8080;
|
||||||
|
private string _hostname;
|
||||||
|
private Grpc.Core.Server _server;
|
||||||
|
private ILibraryService _libraryService;
|
||||||
|
private ISettingsService _settingsService;
|
||||||
|
private IEventManager _eventManager;
|
||||||
|
|
||||||
|
//Implementation class declarations
|
||||||
|
private RemotePartyController _remotePartyController;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor. Registers GRPC service implementations.
|
||||||
|
/// </summary>
|
||||||
|
public ServerService(ILibraryService libraryService, ISettingsService settingsService, IEventManager eventManager)
|
||||||
|
{
|
||||||
|
string host = GetLocalIPAddress();
|
||||||
|
this._libraryService = libraryService;
|
||||||
|
this._settingsService = settingsService;
|
||||||
|
this._eventManager = eventManager;
|
||||||
|
if (string.IsNullOrWhiteSpace(host))
|
||||||
|
{
|
||||||
|
throw new Exception("This device must have a valid IP address");
|
||||||
|
}
|
||||||
|
|
||||||
|
_hostname = host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Port
|
||||||
|
{
|
||||||
|
get { return _port; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Hostname
|
||||||
|
{
|
||||||
|
get { return _hostname; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Initialized
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (_remotePartyController != null &&
|
||||||
|
_server != null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Start Server
|
||||||
|
/// </summary>
|
||||||
|
public void Start(string partyName, string description)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.WriteLine(string.Format("Starting gRPC server at hostname: {0}, port: {1}", _hostname, _port));
|
||||||
|
|
||||||
|
_server = new Grpc.Core.Server
|
||||||
|
{
|
||||||
|
Ports = { new ServerPort(_hostname, _port, ServerCredentials.Insecure) }
|
||||||
|
};
|
||||||
|
|
||||||
|
//Construct implementations
|
||||||
|
_remotePartyController = new RemotePartyController(
|
||||||
|
partyName,
|
||||||
|
description,
|
||||||
|
_libraryService,
|
||||||
|
_settingsService,
|
||||||
|
_eventManager);
|
||||||
|
|
||||||
|
// Register grpc RemoteService with singleton server service
|
||||||
|
RegisterService(RemotePartyService.BindService(_remotePartyController));
|
||||||
|
|
||||||
|
|
||||||
|
_server.Start();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(string.Format("Error starting gRPC server: {0}", ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shutdown server async.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Task</returns>
|
||||||
|
public async Task Stop()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _server.ShutdownAsync();
|
||||||
|
await _server.ShutdownTask;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(string.Format("Error stopping gRPC server: {0}", ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Reset()
|
||||||
|
{
|
||||||
|
await Stop();
|
||||||
|
_server = new Grpc.Core.Server
|
||||||
|
{
|
||||||
|
Ports = { new ServerPort("localhost", _port, ServerCredentials.Insecure) }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RegisterService(ServerServiceDefinition definition)
|
||||||
|
{
|
||||||
|
_server.Services.Add(definition);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetLocalIPAddress()
|
||||||
|
{
|
||||||
|
string returnIp = "";
|
||||||
|
var host = Dns.GetHostEntry(Dns.GetHostName());
|
||||||
|
foreach (var ip in host.AddressList)
|
||||||
|
{
|
||||||
|
if (ip.AddressFamily == AddressFamily.InterNetwork)
|
||||||
|
{
|
||||||
|
returnIp = ip.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnIp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,7 @@ namespace Aurora.Design.Components.NavigationMenu
|
|||||||
public NavigationItem()
|
public NavigationItem()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
public int Id { get; set; }
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public string Group { get; set; }
|
public string Group { get; set; }
|
||||||
public Type TargetType { get; set; }
|
public Type TargetType { get; set; }
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
using Aurora.Models.Media;
|
|
||||||
using Aurora.Design.Views.Main;
|
|
||||||
|
|
||||||
namespace Aurora.Design.Views
|
|
||||||
{
|
|
||||||
public class BasePlayerViewModel : BaseViewModel
|
|
||||||
{
|
|
||||||
public BasePlayerViewModel(): base()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Delegate for interacting with main screen player control
|
|
||||||
/// </summary>
|
|
||||||
/// <value></value>
|
|
||||||
public SetPlayerDelegate ChangePlayerState { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Delegate for checking if main screen player control is currently playing
|
|
||||||
/// </summary>
|
|
||||||
/// <value></value>
|
|
||||||
public GetIsPlayingDelegate IsPlaying { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Command event handler for player play button
|
|
||||||
/// </summary>
|
|
||||||
public virtual void OnPlayButtonCommandExecute() { }
|
|
||||||
public virtual bool CanPlayButtonCommandExecute()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Command event handler for player next button
|
|
||||||
/// </summary>
|
|
||||||
public virtual void OnNextButtonExecute() { }
|
|
||||||
public virtual bool CanNextButtonCommandExecute()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Command event handler for player previous button
|
|
||||||
/// </summary>
|
|
||||||
public virtual void OnPreviousButtonExecute() { }
|
|
||||||
public virtual bool CanPreviousButtonCommandExecute()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,14 +15,55 @@ namespace Aurora.Design.Views
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Player
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Command event handler for player play button
|
||||||
|
/// </summary>
|
||||||
|
public virtual void OnPlayButtonCommandExecute() { }
|
||||||
|
public virtual bool CanPlayButtonCommandExecute()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Command event handler for player next button
|
||||||
|
/// </summary>
|
||||||
|
public virtual void OnNextButtonExecute() { }
|
||||||
|
public virtual bool CanNextButtonCommandExecute()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Command event handler for player previous button
|
||||||
|
/// </summary>
|
||||||
|
public virtual void OnPreviousButtonExecute() { }
|
||||||
|
public virtual bool CanPreviousButtonCommandExecute()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delegate for interacting with main screen player control
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public SetPlayerDelegate ChangePlayerState { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delegate for checking if main screen player control is currently playing
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public GetIsPlayingDelegate IsPlaying { get; set; }
|
||||||
|
|
||||||
public ShowModalDelegate ShowModal { get; set; }
|
public ShowModalDelegate ShowModal { get; set; }
|
||||||
|
|
||||||
public HideModalDelegate HideModal { get; set; }
|
public HideModalDelegate HideModal { get; set; }
|
||||||
|
|
||||||
public SetViewDelegate SetView { get; set; }
|
|
||||||
|
|
||||||
|
#endregion Player
|
||||||
|
|
||||||
#region Lifecycle Callbacks
|
#region Lifecycle
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by main screen on view appearing
|
/// Called by main screen on view appearing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -37,7 +78,7 @@ namespace Aurora.Design.Views
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual Task OnInactive() { return Task.FromResult<object>(null); }
|
public virtual Task OnInactive() { return Task.FromResult<object>(null); }
|
||||||
|
|
||||||
#endregion Lifecycle Callbacks
|
#endregion
|
||||||
|
|
||||||
#region INotifyPropertyChanged Implementation
|
#region INotifyPropertyChanged Implementation
|
||||||
public bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
|
public bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
|
||||||
|
@ -31,12 +31,11 @@ namespace Aurora.Design.Views.Main
|
|||||||
public delegate void ShowModalDelegate(Type view, BaseDialogViewModel viewModel);
|
public delegate void ShowModalDelegate(Type view, BaseDialogViewModel viewModel);
|
||||||
public delegate void HideModalDelegate();
|
public delegate void HideModalDelegate();
|
||||||
public delegate void FinishDialogDelegate();
|
public delegate void FinishDialogDelegate();
|
||||||
public delegate void SetViewDelegate(Type viewType, Type viewModelType);
|
|
||||||
|
|
||||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
public partial class MainView : ContentPage//, IDisposable
|
public partial class MainView : ContentPage//, IDisposable
|
||||||
{
|
{
|
||||||
private Dictionary<string, BaseViewModel> _viewModels;
|
private Dictionary<int, BaseViewModel> _viewModels;
|
||||||
private BaseViewModel _lastViewModel;
|
private BaseViewModel _lastViewModel;
|
||||||
private Player _playerComponent;
|
private Player _playerComponent;
|
||||||
private IPlayer _playerService;
|
private IPlayer _playerService;
|
||||||
@ -46,7 +45,7 @@ namespace Aurora.Design.Views.Main
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
BindingContext = new MainViewModel();
|
BindingContext = new MainViewModel();
|
||||||
_viewModels = new Dictionary<string, BaseViewModel>();
|
_viewModels = new Dictionary<int, BaseViewModel>();
|
||||||
|
|
||||||
_playerComponent = Player;
|
_playerComponent = Player;
|
||||||
|
|
||||||
@ -75,35 +74,29 @@ namespace Aurora.Design.Views.Main
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var view = (View)Activator.CreateInstance(item.TargetType);
|
var view = (View)Activator.CreateInstance(item.TargetType);
|
||||||
string viewModelName = item.TargetViewModelType.Name;
|
|
||||||
|
|
||||||
//Check if we have an instantiated viewModel
|
//Check if we have an instantiated viewModel
|
||||||
BaseViewModel vm = new BaseViewModel();
|
BaseViewModel vm = new BaseViewModel();
|
||||||
if (_viewModels.ContainsKey(viewModelName))
|
if (_viewModels.ContainsKey(item.Id))
|
||||||
{
|
{
|
||||||
_viewModels.TryGetValue(viewModelName, out vm);
|
_viewModels.TryGetValue(item.Id, out vm);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (item.TargetViewModelType.IsAssignableFrom(typeof(BaseViewModel)))
|
if (item.TargetViewModelType.BaseType != typeof(BaseViewModel))
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("TargetViewModel field must be of type BaseViewModel");
|
throw new InvalidOperationException("TargetViewModel field must be of type BaseViewModel");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Instantiate new view model
|
//Instantiate new view model
|
||||||
vm = (BaseViewModel)App.Container.Resolve(item.TargetViewModelType); //Activator.CreateInstance(item.TargetViewModelType);
|
vm = (BaseViewModel)App.Container.Resolve(item.TargetViewModelType); //Activator.CreateInstance(item.TargetViewModelType);
|
||||||
_viewModels.Add(viewModelName, vm);
|
_viewModels.Add(item.Id, vm);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Assign player controls to viewmodel
|
//Assign player controls to viewmodel
|
||||||
if(vm is BasePlayerViewModel)
|
AssignPlayerControls(vm);
|
||||||
{
|
|
||||||
AssignPlayerControls(vm as BasePlayerViewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
ChangeModalVisiblity(false);
|
ChangeModalVisiblity(false);
|
||||||
vm.SetView = this.SetView;
|
|
||||||
|
|
||||||
//Activate viewmodel
|
//Activate viewmodel
|
||||||
vm.OnActive();
|
vm.OnActive();
|
||||||
@ -111,10 +104,7 @@ namespace Aurora.Design.Views.Main
|
|||||||
//Deactivate last viewModel
|
//Deactivate last viewModel
|
||||||
_lastViewModel.OnInactive();
|
_lastViewModel.OnInactive();
|
||||||
//Unasign deactivating vm
|
//Unasign deactivating vm
|
||||||
if(_lastViewModel is BasePlayerViewModel)
|
UnassignPlayerControls(_lastViewModel);
|
||||||
{
|
|
||||||
UnassignPlayerControls(_lastViewModel as BasePlayerViewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Assign viewModel
|
//Assign viewModel
|
||||||
_lastViewModel = vm;
|
_lastViewModel = vm;
|
||||||
@ -138,26 +128,20 @@ namespace Aurora.Design.Views.Main
|
|||||||
var view = (View)Activator.CreateInstance(firstNavItem.TargetType);
|
var view = (View)Activator.CreateInstance(firstNavItem.TargetType);
|
||||||
|
|
||||||
BaseViewModel vm = new BaseViewModel();
|
BaseViewModel vm = new BaseViewModel();
|
||||||
if (_viewModels.ContainsKey(nameof(firstNavItem.TargetViewModelType)))
|
if (_viewModels.ContainsKey(firstNavItem.Id))
|
||||||
{
|
{
|
||||||
_viewModels.TryGetValue(nameof(firstNavItem.TargetViewModelType), out vm);
|
_viewModels.TryGetValue(firstNavItem.Id, out vm);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Instantiate new view model
|
//Instantiate new view model
|
||||||
vm = (BaseViewModel)App.Container.Resolve(firstNavItem.TargetViewModelType); //(BaseViewModel)Activator.CreateInstance(firstNavItem.TargetViewModelType);
|
vm = (BaseViewModel)App.Container.Resolve(firstNavItem.TargetViewModelType); //(BaseViewModel)Activator.CreateInstance(firstNavItem.TargetViewModelType);
|
||||||
_viewModels.Add(nameof(firstNavItem.TargetViewModelType), vm);
|
_viewModels.Add(firstNavItem.Id, vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
view.BindingContext = vm;
|
view.BindingContext = vm;
|
||||||
_lastViewModel = vm;
|
_lastViewModel = vm;
|
||||||
if(vm is BasePlayerViewModel)
|
AssignPlayerControls(vm);
|
||||||
{
|
|
||||||
AssignPlayerControls(vm as BasePlayerViewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
vm.SetView = this.SetView;
|
|
||||||
|
|
||||||
ChangeModalVisiblity(false);
|
ChangeModalVisiblity(false);
|
||||||
vm.OnActive();
|
vm.OnActive();
|
||||||
|
|
||||||
@ -169,7 +153,7 @@ namespace Aurora.Design.Views.Main
|
|||||||
/// Unassign setplayer delegate to prevent vms from changing player info when inactive
|
/// Unassign setplayer delegate to prevent vms from changing player info when inactive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="vm"></param>
|
/// <param name="vm"></param>
|
||||||
private void UnassignPlayerControls(BasePlayerViewModel vm)
|
private void UnassignPlayerControls(BaseViewModel vm)
|
||||||
{
|
{
|
||||||
vm.ChangePlayerState = null;
|
vm.ChangePlayerState = null;
|
||||||
vm.IsPlaying = null;
|
vm.IsPlaying = null;
|
||||||
@ -180,7 +164,7 @@ namespace Aurora.Design.Views.Main
|
|||||||
/// Assign main views music player controls to a view model
|
/// Assign main views music player controls to a view model
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="vm">BaseViewModel to assign controls to</param>
|
/// <param name="vm">BaseViewModel to assign controls to</param>
|
||||||
private void AssignPlayerControls(BasePlayerViewModel vm)
|
private void AssignPlayerControls(BaseViewModel vm)
|
||||||
{
|
{
|
||||||
_playerComponent.PlayButtonCommand = new Command(vm.OnPlayButtonCommandExecute, vm.CanPlayButtonCommandExecute);
|
_playerComponent.PlayButtonCommand = new Command(vm.OnPlayButtonCommandExecute, vm.CanPlayButtonCommandExecute);
|
||||||
_playerComponent.NextButtonCommand = new Command(vm.OnNextButtonExecute, vm.CanNextButtonCommandExecute);
|
_playerComponent.NextButtonCommand = new Command(vm.OnNextButtonExecute, vm.CanNextButtonCommandExecute);
|
||||||
@ -275,53 +259,5 @@ namespace Aurora.Design.Views.Main
|
|||||||
Modal.IsVisible = isVisible;
|
Modal.IsVisible = isVisible;
|
||||||
Content.IsVisible = !isVisible;
|
Content.IsVisible = !isVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetView(Type viewType, Type viewModelType)
|
|
||||||
{
|
|
||||||
BaseViewModel vm = new BaseViewModel();
|
|
||||||
if(this._viewModels.ContainsKey(viewModelType.Name))
|
|
||||||
{
|
|
||||||
this._viewModels.TryGetValue(viewModelType.Name, out vm);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (viewModelType.IsAssignableFrom(typeof(BaseViewModel)))
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("TargetViewModel field must be of type BaseViewModel");
|
|
||||||
}
|
|
||||||
|
|
||||||
//Instantiate new view model
|
|
||||||
vm = (BaseViewModel)App.Container.Resolve(viewModelType); //Activator.CreateInstance(item.TargetViewModelType);
|
|
||||||
_viewModels.Add(viewModelType.Name, vm);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Assign player controls to viewmodel
|
|
||||||
if(vm is BasePlayerViewModel)
|
|
||||||
{
|
|
||||||
AssignPlayerControls(vm as BasePlayerViewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
ChangeModalVisiblity(false);
|
|
||||||
|
|
||||||
//Activate viewmodel
|
|
||||||
vm.OnActive();
|
|
||||||
|
|
||||||
//Deactivate last viewModel
|
|
||||||
_lastViewModel.OnInactive();
|
|
||||||
//Unasign deactivating vm
|
|
||||||
if(_lastViewModel is BasePlayerViewModel)
|
|
||||||
{
|
|
||||||
UnassignPlayerControls(_lastViewModel as BasePlayerViewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
var view = (View)Activator.CreateInstance(viewType);
|
|
||||||
vm.SetView = this.SetView;
|
|
||||||
|
|
||||||
//Assign viewModel
|
|
||||||
_lastViewModel = vm;
|
|
||||||
view.BindingContext = vm;
|
|
||||||
|
|
||||||
_viewContent.Content = view;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -56,13 +56,13 @@ namespace Aurora.Design.Views.MainView
|
|||||||
{
|
{
|
||||||
_pages = new ObservableCollection<NavigationItem>(new[]
|
_pages = new ObservableCollection<NavigationItem>(new[]
|
||||||
{
|
{
|
||||||
new NavigationItem { Title = "Songs", Group="Your Music", TargetType = typeof(SongsView), TargetViewModelType = typeof(SongsViewModel) },
|
new NavigationItem { Id = 0, Title = "Songs", Group="Your Music", TargetType = typeof(SongsView), TargetViewModelType = typeof(SongsViewModel) },
|
||||||
new NavigationItem { Title = "Artists", Group="Your Music", TargetType = typeof(ArtistsView), TargetViewModelType = typeof(ArtistsViewModel)},
|
new NavigationItem { Id = 1, Title = "Artists", Group="Your Music", TargetType = typeof(ArtistsView), TargetViewModelType = typeof(ArtistsViewModel)},
|
||||||
new NavigationItem { Title = "Albums", Group="Your Music", TargetType = typeof(AlbumsView), TargetViewModelType = typeof(AlbumsViewModel)},
|
new NavigationItem { Id = 2, Title = "Albums", Group="Your Music", TargetType = typeof(AlbumsView), TargetViewModelType = typeof(AlbumsViewModel)},
|
||||||
new NavigationItem { Title = "Stations", Group="Your Music", TargetType = typeof(StationsView), TargetViewModelType = typeof(StationsViewModel)},
|
new NavigationItem { Id = 3, Title = "Stations", Group="Your Music", TargetType = typeof(StationsView), TargetViewModelType = typeof(StationsViewModel)},
|
||||||
new NavigationItem { Title = "Party", Group="Social", TargetType = typeof(PartyView), TargetViewModelType = typeof(PartyViewModel)},
|
new NavigationItem { Id = 4, Title = "Party", Group="Social", TargetType = typeof(PartyView), TargetViewModelType = typeof(PartyViewModel)},
|
||||||
new NavigationItem { Title = "Profile", Group="Social", TargetType = typeof(ProfileView), TargetViewModelType = typeof(ProfileViewModel)},
|
new NavigationItem { Id = 5, Title = "Profile", Group="Social", TargetType = typeof(ProfileView), TargetViewModelType = typeof(ProfileViewModel)},
|
||||||
new NavigationItem { Title = "A + B", Group="Playlists", TargetType = typeof(StationsView), TargetViewModelType = typeof(StationsViewModel)}
|
new NavigationItem { Id = 6, Title = "A + B", Group="Playlists", TargetType = typeof(StationsView), TargetViewModelType = typeof(StationsViewModel)}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
using System.Collections.ObjectModel;
|
|
||||||
using Aurora.Proto.Party;
|
|
||||||
using Aurora.Models.Media;
|
|
||||||
using Aurora.Services.Settings;
|
|
||||||
using Aurora.Services;
|
|
||||||
|
|
||||||
namespace Aurora.Design.Views.Party
|
|
||||||
{
|
|
||||||
public class BasePartyViewModel : BasePlayerViewModel
|
|
||||||
{
|
|
||||||
protected string _hostname;
|
|
||||||
protected Global _global;
|
|
||||||
|
|
||||||
protected ISettingsService _settingsService;
|
|
||||||
private ObservableCollection<Member> _members;
|
|
||||||
private ObservableCollection<BaseMedia> _queue;
|
|
||||||
private BaseMedia _selectedMedia;
|
|
||||||
|
|
||||||
private int _selectedTabIndex;
|
|
||||||
|
|
||||||
public BasePartyViewModel(
|
|
||||||
ISettingsService settingsService,
|
|
||||||
Global global
|
|
||||||
)
|
|
||||||
{
|
|
||||||
_members = new ObservableCollection<Member>();
|
|
||||||
_queue = new ObservableCollection<BaseMedia>();
|
|
||||||
|
|
||||||
this._settingsService = settingsService;
|
|
||||||
this._global = global;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int SelectedTabIndex
|
|
||||||
{
|
|
||||||
get { return _selectedTabIndex; }
|
|
||||||
set { SetProperty(ref _selectedTabIndex, value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Publc property for the members list
|
|
||||||
/// </summary>
|
|
||||||
/// <value></value>
|
|
||||||
public ObservableCollection<Member> Members
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _members;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
SetProperty(ref _members, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Public property for the currently selected song.
|
|
||||||
/// </summary>
|
|
||||||
/// <value></value>
|
|
||||||
public BaseMedia SelectedMedia
|
|
||||||
{
|
|
||||||
get { return _selectedMedia; }
|
|
||||||
set { SetProperty(ref _selectedMedia, value); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,225 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Net;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
using Grpc.Core;
|
|
||||||
using Xamarin.Forms;
|
|
||||||
using Aurora.Services.EventManager;
|
|
||||||
using Aurora.Services.Library;
|
|
||||||
using Aurora.Services.Settings;
|
|
||||||
using Aurora.Services;
|
|
||||||
using Aurora.Proto.Party;
|
|
||||||
using Aurora.Models.Media;
|
|
||||||
using Aurora.Services.Controllers;
|
|
||||||
using Aurora.Utils;
|
|
||||||
|
|
||||||
|
|
||||||
namespace Aurora.Design.Views.Party
|
|
||||||
{
|
|
||||||
public class HostPartyViewModel : BasePartyViewModel
|
|
||||||
{
|
|
||||||
private IEventManager _eventManager;
|
|
||||||
private ILibraryService _libraryService;
|
|
||||||
|
|
||||||
private Grpc.Core.Server _server;
|
|
||||||
private RemotePartyController _remotePartyController;
|
|
||||||
private Channel _channel;
|
|
||||||
private int _port = 8080;
|
|
||||||
private bool _isServerStarted = false;
|
|
||||||
|
|
||||||
public HostPartyViewModel(
|
|
||||||
ISettingsService settingsService,
|
|
||||||
IEventManager eventManager,
|
|
||||||
ILibraryService libraryService,
|
|
||||||
Global global
|
|
||||||
): base(settingsService, global)
|
|
||||||
{
|
|
||||||
this._eventManager = eventManager;
|
|
||||||
this._global.State = PartyState.Hosting;
|
|
||||||
this._libraryService = libraryService;
|
|
||||||
|
|
||||||
// Create and start grpc server
|
|
||||||
string host = IpUtil.GetLocalIPAddress();
|
|
||||||
if(string.IsNullOrWhiteSpace(host))
|
|
||||||
{
|
|
||||||
// TODO display error to screen
|
|
||||||
throw new System.Exception("This device does not have a valid IP address");
|
|
||||||
}
|
|
||||||
this._hostname = IpUtil.GetLocalIPAddress();
|
|
||||||
|
|
||||||
this.StartServer("test", "test description");
|
|
||||||
|
|
||||||
// TODO assign members
|
|
||||||
// TODO assign songList
|
|
||||||
|
|
||||||
// Register commands
|
|
||||||
PlayCommand = new Command(OnDoubleClickCommandExecute, CanDoubleClickCommandExecute);
|
|
||||||
LeavePartyCommand = new Command(OnLeavePartyCommandExecute, CanLeavePartyCommandExecute);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Properties
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Public property for playing media command
|
|
||||||
/// </summary>
|
|
||||||
/// <value></value>
|
|
||||||
public Command PlayCommand { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Public property for leave party command
|
|
||||||
/// </summary>
|
|
||||||
/// <value></value>
|
|
||||||
public Command LeavePartyCommand { get; private set; }
|
|
||||||
|
|
||||||
#endregion Properties
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Called by framework when view becomes active
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public override Task OnActive()
|
|
||||||
{
|
|
||||||
// Start server if not already started
|
|
||||||
if(!this._isServerStarted)
|
|
||||||
{
|
|
||||||
this._hostname = IpUtil.GetLocalIPAddress();
|
|
||||||
|
|
||||||
this.StartServer("test", "test description");
|
|
||||||
}
|
|
||||||
return Task.FromResult<object>(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Called by framework when view becomes inactive
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public override Task OnInactive()
|
|
||||||
{
|
|
||||||
return Task.FromResult<object>(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void OnLeavePartyCommandExecute()
|
|
||||||
{
|
|
||||||
await this._channel.ShutdownAsync();
|
|
||||||
await this._server.ShutdownAsync();
|
|
||||||
this._global.State = PartyState.Idle;
|
|
||||||
this.SetView(typeof(PartyView), typeof(PartyViewModel));
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool CanLeavePartyCommandExecute()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnPlayButtonCommandExecute()
|
|
||||||
{
|
|
||||||
if (base.IsPlaying())
|
|
||||||
{
|
|
||||||
//Fire play stopped event
|
|
||||||
AudioMetadata meta = SelectedMedia.Metadata as AudioMetadata;
|
|
||||||
MediaPausedEvent mediaPaused = new MediaPausedEvent();
|
|
||||||
|
|
||||||
_eventManager.FireEvent(new BaseEvent()
|
|
||||||
{
|
|
||||||
MediaPausedEvent = mediaPaused
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Fire play resume event
|
|
||||||
AudioMetadata meta = SelectedMedia.Metadata as AudioMetadata;
|
|
||||||
MediaResumedEvent mediaResumed = new MediaResumedEvent();
|
|
||||||
|
|
||||||
_eventManager.FireEvent(new BaseEvent()
|
|
||||||
{
|
|
||||||
MediaResumedEvent = mediaResumed
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanPlayButtonCommandExecute()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanNextButtonCommandExecute()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanPreviousButtonCommandExecute()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// On double click execute, fire media playing event
|
|
||||||
/// </summary>
|
|
||||||
public void OnDoubleClickCommandExecute()
|
|
||||||
{
|
|
||||||
//Fire Playing event
|
|
||||||
AudioMetadata meta = SelectedMedia.Metadata as AudioMetadata;
|
|
||||||
NewMediaPlayingEvent mediaPlaying = new NewMediaPlayingEvent()
|
|
||||||
{
|
|
||||||
Media = new Media()
|
|
||||||
{
|
|
||||||
//TODO need full resource name
|
|
||||||
Name = SelectedMedia.Id,
|
|
||||||
Title = meta.Title,
|
|
||||||
Artist = meta.Artist,
|
|
||||||
Album = meta.Album,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
_eventManager.FireEvent(new BaseEvent()
|
|
||||||
{
|
|
||||||
NewMediaPlayingEvent = mediaPlaying
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanDoubleClickCommandExecute()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Private Methods
|
|
||||||
|
|
||||||
private void StartServer(string partyName, string description)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
// TODO bmw replace with display in UI
|
|
||||||
Console.WriteLine(string.Format("Starting gRPC server at hostname: {0}, port: {1}", _hostname, _port));
|
|
||||||
|
|
||||||
_server = new Grpc.Core.Server
|
|
||||||
{
|
|
||||||
Ports = { new ServerPort(_hostname, _port, ServerCredentials.Insecure) }
|
|
||||||
};
|
|
||||||
|
|
||||||
//Construct implementations
|
|
||||||
this._remotePartyController = new RemotePartyController(
|
|
||||||
partyName,
|
|
||||||
description,
|
|
||||||
this._libraryService,
|
|
||||||
base._settingsService,
|
|
||||||
_eventManager);
|
|
||||||
|
|
||||||
// Register grpc RemoteService with singleton server service
|
|
||||||
RemotePartyService.BindService(this._remotePartyController);
|
|
||||||
|
|
||||||
|
|
||||||
_server.Start();
|
|
||||||
this._isServerStarted = true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
// TODO bmw replace with display in UI
|
|
||||||
Console.WriteLine(string.Format("Error starting gRPC server: {0}", ex.Message));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion Private Methods
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,39 +1,156 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Linq;
|
||||||
|
using Xamarin.Forms;
|
||||||
using Aurora.Proto.Party;
|
using Aurora.Proto.Party;
|
||||||
|
using Aurora.Models.Media;
|
||||||
|
using Aurora.Services.Client;
|
||||||
using Aurora.Design.Views.Party.NewPartyDialog;
|
using Aurora.Design.Views.Party.NewPartyDialog;
|
||||||
using Aurora.Services.Settings;
|
using Aurora.Services.Settings;
|
||||||
using Aurora.Services;
|
using Aurora.Services.Server;
|
||||||
|
using Aurora.Services.EventManager;
|
||||||
|
using Grpc.Core;
|
||||||
|
|
||||||
namespace Aurora.Design.Views.Party
|
namespace Aurora.Design.Views.Party
|
||||||
{
|
{
|
||||||
|
//TODO refactor
|
||||||
|
enum PartyState
|
||||||
|
{
|
||||||
|
SelectingHost,
|
||||||
|
InParty,
|
||||||
|
Hosting,
|
||||||
|
Connecting,
|
||||||
|
}
|
||||||
delegate void EventHandler(BaseEvent e);
|
delegate void EventHandler(BaseEvent e);
|
||||||
public class PartyViewModel : BasePartyViewModel
|
public class PartyViewModel : BaseViewModel
|
||||||
{
|
{
|
||||||
|
private PartyState _state;
|
||||||
|
private string _hostname = "";
|
||||||
|
private ObservableCollection<Member> _members;
|
||||||
|
private ObservableCollection<BaseMedia> _queue;
|
||||||
|
private BaseMedia _selectedMedia;
|
||||||
|
private ISettingsService _settingsService;
|
||||||
|
private IClientService _clientService;
|
||||||
|
private IServerService _serverService;
|
||||||
|
private IEventManager _eventManager;
|
||||||
|
|
||||||
public PartyViewModel(ISettingsService settingsService, Global global): base(settingsService, global)
|
private CancellationTokenSource _eventCancellationTokenSource;
|
||||||
|
|
||||||
|
private Dictionary<BaseEvent.DerivedEventOneofCase, EventHandler> _eventHandlers;
|
||||||
|
|
||||||
|
private int _selectedTabIndex;
|
||||||
|
|
||||||
|
public PartyViewModel(
|
||||||
|
ISettingsService settingsService,
|
||||||
|
IServerService serverService,
|
||||||
|
IEventManager eventManager,
|
||||||
|
IClientService clientService)
|
||||||
{
|
{
|
||||||
|
_members = new ObservableCollection<Member>();
|
||||||
|
_queue = new ObservableCollection<BaseMedia>();
|
||||||
|
|
||||||
|
this._settingsService = settingsService;
|
||||||
|
this._serverService = serverService;
|
||||||
|
this._eventManager = eventManager;
|
||||||
|
this._clientService = clientService;
|
||||||
|
|
||||||
|
SetState(PartyState.SelectingHost);
|
||||||
|
|
||||||
|
PlayCommand = new Command(OnDoubleClickCommandExecute, CanDoubleClickCommandExecute);
|
||||||
|
|
||||||
|
LeavePartyCommand = new Command(OnLeavePartyCommandExecute, CanLeavePartyCommandExecute);
|
||||||
|
|
||||||
|
//Setup event handlers
|
||||||
|
_eventHandlers = new Dictionary<BaseEvent.DerivedEventOneofCase, EventHandler>()
|
||||||
|
{
|
||||||
|
{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
|
||||||
|
|
||||||
|
public int SelectedTabIndex
|
||||||
|
{
|
||||||
|
get { return _selectedTabIndex; }
|
||||||
|
set { SetProperty(ref _selectedTabIndex, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Publc property for the members list
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public ObservableCollection<Member> Members
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _members;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _members, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Public property for queue item source
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public ObservableCollection<BaseMedia> Queue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _queue;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value != _queue)
|
||||||
|
{
|
||||||
|
SetProperty(ref _queue, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Public property for the currently selected song.
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public BaseMedia SelectedSong
|
||||||
|
{
|
||||||
|
get { return _selectedMedia; }
|
||||||
|
set { SetProperty(ref _selectedMedia, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Public property for playing media
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public Command PlayCommand { get; private set; }
|
||||||
|
|
||||||
|
public Command LeavePartyCommand { get; private set; }
|
||||||
|
|
||||||
|
#endregion Properties
|
||||||
|
|
||||||
|
#region Events
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by framework when view becomes active
|
/// Called by framework when view becomes active
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override Task OnActive()
|
public override async Task OnActive()
|
||||||
{
|
{
|
||||||
OnPropertyChanged("SelectedTabIndex");
|
OnPropertyChanged("SelectedTabIndex");
|
||||||
switch(this._global.State)
|
if (this._state == PartyState.Hosting ||
|
||||||
|
this._state == PartyState.InParty)
|
||||||
{
|
{
|
||||||
case PartyState.Hosting:
|
await this.GetEvents().ConfigureAwait(false);
|
||||||
{
|
|
||||||
this.SetView.Invoke(typeof(PartyView), typeof(HostPartyViewModel));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case PartyState.InParty:
|
else
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
{
|
||||||
//Open host selection modal
|
//Open host selection modal
|
||||||
NewPartyDialogViewModel vm = new NewPartyDialogViewModel();
|
NewPartyDialogViewModel vm = new NewPartyDialogViewModel();
|
||||||
@ -42,28 +159,25 @@ namespace Aurora.Design.Views.Party
|
|||||||
{
|
{
|
||||||
this.HideModal();
|
this.HideModal();
|
||||||
details = vm.ReturnObject as ConnectionDetails;
|
details = vm.ReturnObject as ConnectionDetails;
|
||||||
this._hostname = details.HostName;
|
_hostname = details.HostName;
|
||||||
switch (details.ConnectionType)
|
switch (details.ConnectionType)
|
||||||
{
|
{
|
||||||
case ConnectionType.Host:
|
case ConnectionType.Host:
|
||||||
{
|
{
|
||||||
this.SetView.Invoke(typeof(PartyView), typeof(HostPartyViewModel));
|
OnHostCommandExecute();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ConnectionType.Join:
|
case ConnectionType.Join:
|
||||||
{
|
{
|
||||||
// TODO
|
OnJoinCommandExecute();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.ShowModal(typeof(NewPartyDialog.NewPartyDialog), vm);
|
this.ShowModal(typeof(NewPartyDialog.NewPartyDialog), vm);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Task.FromResult<object>(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by framework when view becomes inactive
|
/// Called by framework when view becomes inactive
|
||||||
@ -71,11 +185,393 @@ namespace Aurora.Design.Views.Party
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override Task OnInactive()
|
public override Task OnInactive()
|
||||||
{
|
{
|
||||||
// if(this._eventCancellationTokenSource != null){
|
if(this._eventCancellationTokenSource != null){
|
||||||
// this._eventCancellationTokenSource.Cancel();
|
this._eventCancellationTokenSource.Cancel();
|
||||||
// }
|
}
|
||||||
|
|
||||||
return Task.FromResult<object>(null);
|
return Task.FromResult<object>(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remote media paused event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="args"></param>
|
||||||
|
public void OnRemoteMediaPaused(BaseEvent e)
|
||||||
|
{
|
||||||
|
StopPlaying();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remote playing new media event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="args"></param>
|
||||||
|
public void OnNewRemoteMediaPlaying(BaseEvent e)
|
||||||
|
{
|
||||||
|
PlayFromBeginning(GetMediaFromQueue(e.NewMediaPlayingEvent.Media.Name));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remote resumed playing event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="args"></param>
|
||||||
|
public void OnRemoteMediaResumed(BaseEvent e)
|
||||||
|
{
|
||||||
|
PlayResume();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Member joined party event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="args"></param>
|
||||||
|
public void OnPartyMemberJoined(BaseEvent e)
|
||||||
|
{
|
||||||
|
Members.Add(e.MemberCreatedEvent.Member);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Member left party event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="args"></param>
|
||||||
|
public void OnPartyMemberLeft(BaseEvent e)
|
||||||
|
{
|
||||||
|
var found = Members.Where(x => x.Name == e.MemberDeletedEvent.MemberName);
|
||||||
|
foreach (Member member in found)
|
||||||
|
{
|
||||||
|
_members.Remove(member);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Events
|
||||||
|
|
||||||
|
#region Commands
|
||||||
|
private async void OnJoinCommandExecute()
|
||||||
|
{
|
||||||
|
SetState(PartyState.Connecting);
|
||||||
|
_clientService.Start(_hostname, this._settingsService.DefaultPort.ToString());
|
||||||
|
await JoinParty(false);
|
||||||
|
|
||||||
|
//TODO add cancellation token
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SetState(PartyState.InParty);
|
||||||
|
await GetEvents().ConfigureAwait(true);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Exception occurred while receiviing events: ", ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool CanJoinCommandExecute()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnHostCommandExecute()
|
||||||
|
{
|
||||||
|
//Change state
|
||||||
|
SetState(PartyState.Connecting);
|
||||||
|
_serverService.Start("test", "asdf");
|
||||||
|
string localHost = ServerService.GetLocalIPAddress();
|
||||||
|
_clientService.Start(localHost, this._settingsService.DefaultPort.ToString());
|
||||||
|
await JoinParty(true);
|
||||||
|
|
||||||
|
|
||||||
|
//TODO add cancellation token
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SetState(PartyState.Hosting);
|
||||||
|
await GetEvents().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Exception occurred while receiviing events: ", ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool CanHostCommandExecute()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnLeavePartyCommandExecute()
|
||||||
|
{
|
||||||
|
await _clientService.RemotePartyServiceClient.DeleteMemberAsync(new DeleteMemberRequest()
|
||||||
|
{
|
||||||
|
Name = _settingsService.ClientName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool CanLeavePartyCommandExecute()
|
||||||
|
{
|
||||||
|
return (this._state == PartyState.InParty || this._state == PartyState.Hosting) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnPlayButtonCommandExecute()
|
||||||
|
{
|
||||||
|
if (base.IsPlaying())
|
||||||
|
{
|
||||||
|
//Fire play stopped event
|
||||||
|
AudioMetadata meta = _selectedMedia.Metadata as AudioMetadata;
|
||||||
|
MediaPausedEvent mediaPaused = new MediaPausedEvent();
|
||||||
|
|
||||||
|
_eventManager.FireEvent(new BaseEvent()
|
||||||
|
{
|
||||||
|
MediaPausedEvent = mediaPaused
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Fire play resume event
|
||||||
|
AudioMetadata meta = _selectedMedia.Metadata as AudioMetadata;
|
||||||
|
MediaResumedEvent mediaResumed = new MediaResumedEvent();
|
||||||
|
|
||||||
|
_eventManager.FireEvent(new BaseEvent()
|
||||||
|
{
|
||||||
|
MediaResumedEvent = mediaResumed
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanPlayButtonCommandExecute()
|
||||||
|
{
|
||||||
|
return this._state == PartyState.Hosting;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanNextButtonCommandExecute()
|
||||||
|
{
|
||||||
|
return this._state == PartyState.Hosting;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanPreviousButtonCommandExecute()
|
||||||
|
{
|
||||||
|
return this._state == PartyState.Hosting;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// On double click execute, fire media playing event
|
||||||
|
/// </summary>
|
||||||
|
public void OnDoubleClickCommandExecute()
|
||||||
|
{
|
||||||
|
//Fire Playing event
|
||||||
|
AudioMetadata meta = _selectedMedia.Metadata as AudioMetadata;
|
||||||
|
NewMediaPlayingEvent mediaPlaying = new NewMediaPlayingEvent()
|
||||||
|
{
|
||||||
|
Media = new Media()
|
||||||
|
{
|
||||||
|
//TODO need full resource name
|
||||||
|
Name = _selectedMedia.Id,
|
||||||
|
Title = meta.Title,
|
||||||
|
Artist = meta.Artist,
|
||||||
|
Album = meta.Album,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
_eventManager.FireEvent(new BaseEvent()
|
||||||
|
{
|
||||||
|
NewMediaPlayingEvent = mediaPlaying
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanDoubleClickCommandExecute()
|
||||||
|
{
|
||||||
|
return this._state == PartyState.Hosting;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion Commands
|
||||||
|
|
||||||
|
#region Private Methods
|
||||||
|
/// <summary>
|
||||||
|
/// Join the remote party.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task JoinParty(bool asHost)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Member resp = await _clientService.RemotePartyServiceClient.CreateMemberAsync(new CreateMemberRequest
|
||||||
|
{
|
||||||
|
Member = new Member()
|
||||||
|
{
|
||||||
|
UserName = this._settingsService.Username,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this._settingsService.ClientName = resp.Name;
|
||||||
|
|
||||||
|
await RefreshMembers();
|
||||||
|
|
||||||
|
//Subscribe to events
|
||||||
|
await SubscribeToEvents();
|
||||||
|
|
||||||
|
Queue.Clear();
|
||||||
|
|
||||||
|
ListMediaResponse mediaResponse = await _clientService.RemotePartyServiceClient.ListMediaAsync(new ListMediaRequest()
|
||||||
|
{
|
||||||
|
PageSize = 50,
|
||||||
|
Parent = "TODO"
|
||||||
|
});
|
||||||
|
|
||||||
|
//Convert received data to remote audio models
|
||||||
|
foreach (Media data in mediaResponse.Media)
|
||||||
|
{
|
||||||
|
//Assign received metadata (since this can't be aquired from a file)
|
||||||
|
AudioMetadata meta = new AudioMetadata();
|
||||||
|
meta.Title = data.Title;
|
||||||
|
meta.Album = data.Album;
|
||||||
|
meta.Artist = data.Artist;
|
||||||
|
meta.Duration = data.Duration;
|
||||||
|
|
||||||
|
RemoteAudio remote = new RemoteAudio(data.Name,
|
||||||
|
asHost,
|
||||||
|
meta,
|
||||||
|
_clientService.RemotePartyServiceClient);
|
||||||
|
|
||||||
|
Queue.Add(remote);
|
||||||
|
OnPropertyChanged("Queue");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error subscribing to events: " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LeaveParty()
|
||||||
|
{
|
||||||
|
//Stop receiving events
|
||||||
|
// _client.StopEvents();
|
||||||
|
|
||||||
|
//Unsubscribe
|
||||||
|
await UnsubscribeFromEvents();
|
||||||
|
|
||||||
|
//Leave party
|
||||||
|
DeleteMemberRequest req = new DeleteMemberRequest()
|
||||||
|
{
|
||||||
|
Name = _settingsService.ClientName
|
||||||
|
};
|
||||||
|
|
||||||
|
await _clientService.RemotePartyServiceClient.DeleteMemberAsync(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SubscribeToEvents()
|
||||||
|
{
|
||||||
|
CreateEventSubscriptionListRequest req = new CreateEventSubscriptionListRequest();
|
||||||
|
req.Parent = this._settingsService.ClientName;
|
||||||
|
req.EventSubscriptions.Add(new EventSubscription() { Type = EventType.MemberCreated });
|
||||||
|
req.EventSubscriptions.Add(new EventSubscription() { Type = EventType.MemberDeleted });
|
||||||
|
req.EventSubscriptions.Add(new EventSubscription() { Type = EventType.MediaPlaying });
|
||||||
|
req.EventSubscriptions.Add(new EventSubscription() { Type = EventType.MediaStopped });
|
||||||
|
|
||||||
|
Console.WriteLine(string.Format("CLIENT {0} - SubscribeToEvents called from client with id", this._settingsService.ClientName));
|
||||||
|
await _clientService.RemotePartyServiceClient.CreateEventSubscriptionListAsync(req);
|
||||||
|
}
|
||||||
|
private async Task UnsubscribeFromEvents()
|
||||||
|
{
|
||||||
|
DeleteAllEventSubscriptionsRequest unsubscribeReq = new DeleteAllEventSubscriptionsRequest();
|
||||||
|
await _clientService.RemotePartyServiceClient.DeleteAllEventSubscriptionsAsync(unsubscribeReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Refresh members list.
|
||||||
|
/// </summary>
|
||||||
|
private async Task RefreshMembers()
|
||||||
|
{
|
||||||
|
Members.Clear();
|
||||||
|
ListMembersResponse response = await _clientService.RemotePartyServiceClient.ListMembersAsync(
|
||||||
|
new ListMembersRequest()
|
||||||
|
{
|
||||||
|
Parent = "TODO",
|
||||||
|
PageSize = 50,
|
||||||
|
});
|
||||||
|
//Add members
|
||||||
|
foreach (Member member in response.Members)
|
||||||
|
{
|
||||||
|
Members.Add(member);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetState(PartyState state)
|
||||||
|
{
|
||||||
|
_state = state;
|
||||||
|
OnPropertyChanged("IsSelectingHost");
|
||||||
|
OnPropertyChanged("IsNotSelectingHost");
|
||||||
|
}
|
||||||
|
|
||||||
|
private BaseMedia GetMediaFromQueue(string Id)
|
||||||
|
{
|
||||||
|
if (_queue.Any((BaseMedia media) => media.Id == Id))
|
||||||
|
{
|
||||||
|
BaseMedia media = _queue.First((BaseMedia med) => med.Id == Id);
|
||||||
|
return media;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void PlayFromBeginning(BaseMedia args)
|
||||||
|
{
|
||||||
|
base.ChangePlayerState(args, Main.PlayAction.Play);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PlayResume()
|
||||||
|
{
|
||||||
|
base.ChangePlayerState(null, Main.PlayAction.Resume);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StopPlaying()
|
||||||
|
{
|
||||||
|
base.ChangePlayerState(null, Main.PlayAction.Pause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronous function for processing events off of the event stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task GetEvents()
|
||||||
|
{
|
||||||
|
_eventCancellationTokenSource = new CancellationTokenSource();
|
||||||
|
string clientName = this._settingsService.ClientName;
|
||||||
|
Console.WriteLine(string.Format("CLIENT {0} - GetEvents called from client with id", clientName));
|
||||||
|
using (AsyncServerStreamingCall<BaseEvent> eventStream = _clientService.RemotePartyServiceClient
|
||||||
|
.GetEvents(new GetEventsRequest { Parent = this._settingsService.ClientName }))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while (!_eventCancellationTokenSource.Token.IsCancellationRequested &&
|
||||||
|
await eventStream.ResponseStream.MoveNext(_eventCancellationTokenSource.Token))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
BaseEvent e = new BaseEvent(eventStream.ResponseStream.Current);
|
||||||
|
|
||||||
|
_eventHandlers.TryGetValue(e.DerivedEventCase, out EventHandler handler);
|
||||||
|
|
||||||
|
if (handler != null && handler != null)
|
||||||
|
{
|
||||||
|
handler.Invoke(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Exception while parsing event ---" + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(string.Format("EXCEPTION while parsing events --- " + ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion Private Methods
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ using Xamarin.Forms;
|
|||||||
|
|
||||||
namespace Aurora.Design.Views.Songs
|
namespace Aurora.Design.Views.Songs
|
||||||
{
|
{
|
||||||
public class SongsViewModel : BasePlayerViewModel
|
public class SongsViewModel : BaseViewModel
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
private ObservableCollection<BaseMedia> _songsList;
|
private ObservableCollection<BaseMedia> _songsList;
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
using System.Net;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
|
|
||||||
namespace Aurora.Utils
|
|
||||||
{
|
|
||||||
public static class IpUtil
|
|
||||||
{
|
|
||||||
public static string GetLocalIPAddress()
|
|
||||||
{
|
|
||||||
string returnIp = "";
|
|
||||||
var host = Dns.GetHostEntry(Dns.GetHostName());
|
|
||||||
foreach (var ip in host.AddressList)
|
|
||||||
{
|
|
||||||
if (ip.AddressFamily == AddressFamily.InterNetwork)
|
|
||||||
{
|
|
||||||
returnIp = ip.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return returnIp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +1,5 @@
|
|||||||
{
|
{
|
||||||
"folders": ['
|
"folders": [
|
||||||
{
|
|
||||||
"path": ".gitea"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"path": "aurora-sharp-desktop"
|
"path": "aurora-sharp-desktop"
|
||||||
},
|
},
|
||||||
@ -13,7 +10,7 @@
|
|||||||
"path": "aurora-proto"
|
"path": "aurora-proto"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "aurora-shared"
|
"path": ".gitea"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
|
Loading…
Reference in New Issue
Block a user