public PlaylistEventArgs(List<SongTag> playlist, List<SongTag> playlistchanges, Status status, SongTag currentsong) { this.playlist = playlist; this.playlistchanges = playlistchanges; this.status = status; this.currentsong = currentsong; }
public async Task<Tuple<Stats, Status>> TestPermission() { //var qId = await Send(MPDKeyWords.Send.Encode( MPDKeyWords.Client.Status.STATS ), true, false, true); bool success = await Connection.Send(_connection.Socket, MPDKeyWords.Send.Encode(MPDKeyWords.Client.Status.STATS)); if (!success) return null; string response = await Connection.Recive(_connection.Socket, new List<string>() { MPDKeyWords.Response.SUCCESS_CONNECT }, new List<string>() { MPDKeyWords.Response.OK + MPDKeyWords.Response.LINEBREAK }, new List<string>() { MPDKeyWords.Response.ACK }, new List<string>() { MPDKeyWords.Response.LINEBREAK }); //var response = await Response(qId); if (string.IsNullOrEmpty(response) || response.Contains(MPDKeyWords.Response.ACK)) return null; var stats = new Stats((await MPDKeyWords.Response.Encode(response)).FirstOrDefault()); //qId = await Send(MPDKeyWords.Send.Encode( MPDKeyWords.Client.Status.STATUS ), true, false, true); //response = await Response(qId); success = await Connection.Send(_connection.Socket, MPDKeyWords.Send.Encode(MPDKeyWords.Client.Status.STATUS)); if (!success) return null; response = await Connection.Recive(_connection.Socket, new List<string>() { MPDKeyWords.Response.SUCCESS_CONNECT }, new List<string>() { MPDKeyWords.Response.OK + MPDKeyWords.Response.LINEBREAK }, new List<string>() { MPDKeyWords.Response.ACK }, new List<string>() { MPDKeyWords.Response.LINEBREAK }); if (string.IsNullOrEmpty(response) || response.Contains(MPDKeyWords.Response.ACK)) return null; var status = new Status((await MPDKeyWords.Response.Encode(response)).FirstOrDefault()); return new Tuple<Stats, Status>(stats, status); }
public OutputEventArgs(List<Output> outputs, Status status) { this.outputs = outputs; this.status = status; }
public PlayerEventArgs(SongTag currentsong, Status status) { this.currentsong = currentsong; this.status = status; }
public UpdateEventArgs(Status status, bool IsUpdating, Stats stats) { this.status = status; this.IsUpdating = IsUpdating; this.stats = stats; }
public StatusEventArgs(Status status) { this.status = status; }
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; }
public async Task<bool> Start(Status status = null, bool silent = false) { var success = await Connect(this.host, this.port, this.password, silent); if (success) { if (status == null) this.status = await GetStatus(); else this.status = status; idle = true; IdleEventLoop(); } else idle = false; return success; }
public async Task<bool> RefreshConnection(Status status = null) { //idle = false; await Stop(); bool suc = await Start(status, false); return suc; }