private void SetUpEvents() { _hubConnection.On <CurrentSong>("startSongCommandNotification", currentSong => { OnSongStarted?.Invoke(this, currentSong); }); _hubConnection.On <CurrentSong>("finishSongCommandNotification", currentSong => { OnSongFinished?.Invoke(this, currentSong); }); _hubConnection.On <Song>("addSongCommandNotification", song => { OnSongAdded?.Invoke(this, song); }); _hubConnection.On <SongToRemove>("removeSongCommandNotification", song => { OnRemoveSong?.Invoke(this, song); }); _hubConnection.On("endSessionCommandNotification", () => { OnSessionEnded?.Invoke(this, null); }); _hubConnection.On("startSessionCommandNotification", () => { OnRemoveSong?.Invoke(this, null); }); }
/// <summary> /// Handle specific events based on state changes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Sniffer_OnStateChanged(object sender, OnStateChangedArgs e) { var newState = e.newState; var oldState = e.oldState; if (oldState == SnifferState.IN_MENUS && newState == SnifferState.SONG_STARTING) { OnSongStarted?.Invoke(this, new OnSongStartedArgs { song = currentCDLCDetails }); } else if (newState == SnifferState.IN_MENUS && oldState != SnifferState.NONE) { OnSongEnded?.Invoke(this, new OnSongEndedArgs { song = currentCDLCDetails }); } }