private async Task ActionOnEventLoop()
{
Status status = null;
Stats stats = null;
SongTag currentsong = null;
for (int i = 0; i < responselist.Count; i++)
{
string response = responselist[i];
switch (response)
{
case ("database"):
if (stats == null) stats = await this.Stats();
if (OnDatabase != null) OnDatabase(this, new StatsEventArgs(stats));
break;
case ("update"):
if (status == null) status = await this.GetStatus();
if (stats == null) stats = await this.Stats();
if (OnUpdate != null) OnUpdate(this, new UpdateEventArgs(status, status.IsDbUpdating, stats));
break;
case ("stored_playlist"):
if (OnStoredPlaylist != null) OnStoredPlaylist(this, new StoredPlaylistEventArgs(await this.ListPlaylists()));
break;
case ("playlist"):
if (currentsong == null) currentsong = await this.CurrentSong();
if (status == null) status = await this.GetStatus();
List<SongTag> playlist = await this.Playlist();
List<SongTag> playlistchanges = await this.PlaylistChanges(this.status.Playlist);
if (OnPlaylist != null) OnPlaylist(this, new PlaylistEventArgs(playlist, playlistchanges, status, currentsong));
break;
case ("player"):
if (currentsong == null) currentsong = await this.CurrentSong();
if (status == null) status = await this.GetStatus();
if (OnPlayer != null) OnPlayer(this, new PlayerEventArgs(currentsong, status));
break;
case ("mixer"):
if (status == null) status = await this.GetStatus();
if (OnMixer != null) OnMixer(this, new StatusEventArgs(status));
break;
case ("output"):
if (status == null) status = await this.GetStatus();
if (OnOutput != null) OnOutput(this, new OutputEventArgs(await this.Outputs(), status));
break;
case ("options"):
if (status == null) status = await this.GetStatus();
if (OnOptions != null) OnOptions(this, new StatusEventArgs(status));
break;
case ("sticker"):
if (OnSticker != null) OnSticker(this, new EventArgs());
break;
case ("subscription"):
//if (OnSubscription != null) OnSubscription(this, new EventArgs());
break;
case ("message"):
//if (OnMessage != null) OnMessage(this, new MessageEventArgs(await ReadMessages()));
break;
default:
break;
}
}
if (status != null) this.status = status;
}