diff --git a/Aurora/Design/Views/Party/PartyViewModel.cs b/Aurora/Design/Views/Party/PartyViewModel.cs
index ddf4a9c..0ea29ee 100644
--- a/Aurora/Design/Views/Party/PartyViewModel.cs
+++ b/Aurora/Design/Views/Party/PartyViewModel.cs
@@ -48,6 +48,12 @@ namespace Aurora.Design.Views.Party
PlayCommand = new Command(OnDoubleClickExecute, CanDoubleClickExecute);
_client = ClientService.Instance;
+
+ _client.OnMediaPaused += this.OnMediaPaused;
+ _client.OnMediaResumed += this.OnMediaResumed;
+ _client.OnNewMediaPlaying += this.OnNewMediaPlaying;
+ _client.OnPartyMemberJoined += this.OnPartyMemberJoined;
+ _client.OnPartyMemberLeft += this.OnPartyMemberLeft;
}
~PartyViewModel()
@@ -155,16 +161,11 @@ namespace Aurora.Design.Views.Party
///
public override async Task OnActive()
{
- //TODO
- if (this._state == PartyState.Hosting)
+ if (this._state == PartyState.Hosting ||
+ this._state == PartyState.InParty)
{
- await SubscribeToEvents();
+ await _client.GetEvents().ConfigureAwait(false);
}
- _client.OnMediaPaused += this.OnMediaPaused;
- _client.OnMediaResumed += this.OnMediaResumed;
- _client.OnNewMediaPlaying += this.OnNewMediaPlaying;
- _client.OnPartyMemberJoined += this.OnPartyMemberJoined;
- _client.OnPartyMemberLeft += this.OnPartyMemberLeft;
}
///
@@ -174,14 +175,6 @@ namespace Aurora.Design.Views.Party
public override async Task OnInactive()
{
_client.StopEvents();
- await UnsubscribeFromEvents();
- //Stop event stream and un hook events
-
- _client.OnMediaPaused -= this.OnMediaPaused;
- _client.OnMediaResumed -= this.OnMediaResumed;
- _client.OnNewMediaPlaying -= this.OnNewMediaPlaying;
- _client.OnPartyMemberJoined -= this.OnPartyMemberJoined;
- _client.OnPartyMemberLeft -= this.OnPartyMemberLeft;
}
///
diff --git a/Aurora/Services/ClientService/ClientService.cs b/Aurora/Services/ClientService/ClientService.cs
index 9c58d25..6aeb47b 100644
--- a/Aurora/Services/ClientService/ClientService.cs
+++ b/Aurora/Services/ClientService/ClientService.cs
@@ -74,9 +74,6 @@ namespace Aurora.Services.ClientService
_remoteEventsClient = new RemoteEventService.RemoteEventServiceClient(_channel);
_remotePlaybackClient = new RemotePlaybackService.RemotePlaybackServiceClient(_channel);
_remoteSyncClient = new RemoteSyncService.RemoteSyncServiceClient(_channel);
-
- //Assign but don't start task
- _eventCancellationTokenSource = new CancellationTokenSource();
}
public async void Close()
@@ -96,6 +93,7 @@ namespace Aurora.Services.ClientService
///
public async Task GetEvents()
{
+ _eventCancellationTokenSource = new CancellationTokenSource();
string clientId = SettingsService.Instance.ClientId;
Console.WriteLine(string.Format("CLIENT {0} - GetEvents called from client with id", clientId));
using (AsyncServerStreamingCall eventStream = _remoteEventsClient
diff --git a/Aurora/Services/EventManager/EventManager.cs b/Aurora/Services/EventManager/EventManager.cs
index ffdb1b3..cd5858a 100644
--- a/Aurora/Services/EventManager/EventManager.cs
+++ b/Aurora/Services/EventManager/EventManager.cs
@@ -181,18 +181,24 @@ namespace Aurora.Services.EventManager
if (actionsCopy.ContainsKey(pair.Key))
{
actionsCopy.TryGetValue(pair.Key, out Action action);
+ Task executionTask = new Task(() => action(bEvent));
+ executionTask.ContinueWith((Task task) => ExceptionHandler(task, pair.Key),
+ TaskContinuationOptions.OnlyOnFaulted);
- ParameterizedThreadStart operation = new ParameterizedThreadStart(obj => action((BaseEvent)obj));
- Thread executionThread = new Thread(operation, 1024 * 1024);
-
- executionThread.Start(bEvent);
- executionThread.Join();
+ executionTask.Start();
}
}
}
}
+ private void ExceptionHandler(Task executionTask, string actionKey)
+ {
+ var exception = executionTask.Exception;
+ Console.WriteLine(string.Format("SERVER --- Exception occurred firing event"));
+ this._actionList.Remove(actionKey);
+ }
+
#endregion Public Methods
}