public async Task ConnectToParty(string partyCode) { PartyGoer partier = await _partyGoerService.GetCurrentPartyGoerAsync(); if (!await _partyService.IsUserPartyingAsync(partier) && !await _partyService.IsUserHostingAPartyAsync(partier)) { await _partyService.JoinPartyAsync(new Domain.DTO.PartyCodeDTO { PartyCode = partyCode }, partier); await Groups.AddToGroupAsync(Context.ConnectionId, partyCode); await Clients.Group(partyCode).SendAsync("UpdateParty", $"{Context.UserIdentifier} has joined the party {partyCode}"); } // Add the partier to real-time connection group await Groups.AddToGroupAsync(Context.ConnectionId, partyCode); await Clients.Group(partyCode).SendAsync("UpdateParty", $"{Context.UserIdentifier} has joined the party {partyCode}"); await Clients.Group(partyCode).SendAsync("NewListener", Context.UserIdentifier); Party party = await _partyService.GetPartyWithAttendeeAsync(partier); // Update the view of the partier to the current playlist await Clients.Client(Context.ConnectionId).SendAsync("UpdatePartyView", new { Song = party.Playlist.CurrentSong, Position = party.Playlist.CurrentPositionInSong() }, party.Playlist.History, party.Playlist.Queue ); // check for explicit music if (partier.FilterExplicitSongs && party.HasExplicitSongs()) { await Clients.Client(Context.ConnectionId).SendAsync("ExplicitSong", "You have filtering explicit music turned on in Spotify and there are explicit songs in the queue. We will not play the explicit song for you but continue playback when a non explicit song comes on."); } await Clients.Client(Context.ConnectionId).SendAsync("InitializeWebPlayer", await _partyGoerService.GetPartyGoerAccessTokenAsync(partier)); // make sure that the users spotify is connected if (string.IsNullOrEmpty(await _spotifyHttpClient.GetUsersActiveDeviceAsync(partier.Id))) { await Clients.Client(Context.ConnectionId).SendAsync("ConnectSpotify", ""); } await _logService.LogUserActivityAsync(partier, $"Joined real time collobration in party with code {partyCode}"); return; }
public async Task <IActionResult> GetPartyGoerSpotifyAccessToken() { return(new JsonResult(new { AccessToken = await _partyGoerService.GetPartyGoerAccessTokenAsync(await _partyGoerService.GetCurrentPartyGoerAsync()) })); }