Fixed issue with Horizontal list not refreshing. Added clientId to joinPartyResponse. Crashing on multiple user joins.

This commit is contained in:
watsonb8
2019-07-12 11:34:06 -04:00
parent 11a585ecc0
commit d78dce44f0
11 changed files with 173 additions and 54 deletions

View File

@ -39,11 +39,8 @@ namespace Aurora.Design.Views.Party
{
this.JoinCommand = new Command(OnJoinExecute, CanJoinExecute);
this.HostCommand = new Command(OnHostExecute, CanHostExecute);
_members = new ObservableCollection<PartyMember>
{
new PartyMember{UserName = "asdf"}
};
_members = new ObservableCollection<PartyMember>();
SetState(PartyState.SelectingHost);
}
@ -142,17 +139,24 @@ namespace Aurora.Design.Views.Party
/// <returns></returns>
private async void JoinParty()
{
await _remotePartyClient.JoinPartyAsync(new JoinPartyRequest
JoinPartyResponse resp = await _remotePartyClient.JoinPartyAsync(new JoinPartyRequest
{
UserName = SettingsService.Instance.Username,
});
SettingsService.Instance.ClientId = resp.ClientId;
RefreshMembers();
//Subscribe to events
SubscribeRequest req = new SubscribeRequest();
req.EventTypes.Add(EventType.PartyMemberJoined);
req.EventTypes.Add(EventType.PartyMemberLeft);
if (!string.IsNullOrWhiteSpace(SettingsService.Instance.ClientId))
{
req.ClientId = SettingsService.Instance.ClientId;
}
try
{
_remoteEventsClient.SubscribeToEvents(req);
@ -202,11 +206,13 @@ namespace Aurora.Design.Views.Party
/// <returns></returns>
private async void GetEvents()
{
using (AsyncServerStreamingCall<BaseEvent> eventStream = _remoteEventsClient.GetEvents(new Empty()))
using (AsyncServerStreamingCall<BaseEvent> eventStream = _remoteEventsClient
.GetEvents(new EventsRequest { ClientId = SettingsService.Instance.ClientId }))
{
while (!_eventCancellationTokenSource.Token.IsCancellationRequested)
while (!_eventCancellationTokenSource.Token.IsCancellationRequested &&
await eventStream.ResponseStream.MoveNext(_eventCancellationTokenSource.Token))
{
if (await eventStream.ResponseStream.MoveNext(_eventCancellationTokenSource.Token))
try
{
//Convert derived event type
BaseEvent e = eventStream.ResponseStream.Current;
@ -233,6 +239,11 @@ namespace Aurora.Design.Views.Party
break;
}
}
}
catch (Exception ex)
{
Console.WriteLine(string.Format("EXCEPTION --- " + ex.Message));
}
}
}