private void PublishDuration() { ByteQueue queue = new ByteQueue(); queue.Enqueue(Duration); Publish(nameof(Duration), queue); }
private void PublishSearchKey() { ByteQueue queue = new ByteQueue(); queue.Enqueue(SearchKey); Publish(nameof(SearchKey), queue); }
private void PublishServiceVolume() { ByteQueue queue = new ByteQueue(); queue.Enqueue(Volume); Publish(nameof(Volume), queue); }
private void PublishAllSongsShuffled() { ByteQueue queue = new ByteQueue(); queue.Enqueue(AllSongsShuffled); Publish(nameof(AllSongsShuffled), queue); }
protected override void OnPositionChanged() { ByteQueue queue = new ByteQueue(); queue.Enqueue(Position); Publish(nameof(Position), queue); }
protected override void OnSearchKeyChanged() { ByteQueue queue = new ByteQueue(); queue.Enqueue(SearchKey); Publish(nameof(SearchKey), queue); }
protected override void OnMediaSourcesChanged() { ByteQueue queue = new ByteQueue(); queue.Enqueue(MediaSources); Publish(nameof(MediaSources), queue); }
protected override void OnPlayStateChanged() { ByteQueue queue = new ByteQueue(); queue.Enqueue(PlayState); Publish(nameof(PlayState), queue); }
protected override void OnIsOnlySearchChanged() { ByteQueue queue = new ByteQueue(); queue.Enqueue(IsOnlySearch); Publish(nameof(IsOnlySearch), queue); }
protected override void OnIsSearchShuffleChanged() { ByteQueue queue = new ByteQueue(); queue.Enqueue(IsSearchShuffle); Publish(nameof(IsSearchShuffle), queue); }
private void PublishPosition() { ByteQueue queue = new ByteQueue(); queue.Enqueue(Position); Publish(nameof(Position), queue); }
private void PublishPlayState() { ByteQueue queue = new ByteQueue(); queue.Enqueue(PlayState); Publish(nameof(PlayState), queue); }
private void PublishIsSearchShuffle() { ByteQueue queue = new ByteQueue(); queue.Enqueue(IsSearchShuffle); Publish(nameof(IsSearchShuffle), queue); }
private void PublishIsOnlySearch() { ByteQueue queue = new ByteQueue(); queue.Enqueue(IsOnlySearch); Publish(nameof(IsOnlySearch), queue); }
protected override void OnCurrentSongChanged() { ByteQueue queue = new ByteQueue(); if (CurrentSong.HasValue) { queue.Enqueue(CurrentSong.Value); } Publish(nameof(CurrentSong), queue); }
private void PublishCurrentSong() { ByteQueue queue = new ByteQueue(); if (CurrentSong.HasValue) { queue.Enqueue(CurrentSong.Value); } Publish(nameof(CurrentSong), queue); }
private void PublishMediaSources() { ByteQueue queue = new ByteQueue(); if (MediaSources != null) { queue.Enqueue(MediaSources); } Publish(nameof(MediaSources), queue); }
private void PublishFormat() { ByteQueue queue = new ByteQueue(); if (Format != null) { queue.Enqueue(Format); } Publish(nameof(Format), queue, MqttQualityOfServiceLevel.AtLeastOnce); }
private void OnApplicationMessageInterception(MqttApplicationMessageInterceptorContext context) { if (context.ClientId == null) { return; } messageInterceptingTopics.Add(context.ApplicationMessage.Topic); ByteQueue queue = context.ApplicationMessage.Payload; try { switch (context.ApplicationMessage.Topic) { case nameof(AllSongsShuffled): Reload(); queue = new ByteQueue(); queue.Enqueue(AllSongsShuffled); context.ApplicationMessage.Payload = queue; break; case nameof(CurrentSong): CurrentSong = queue.Any() ? (Song?)queue.DequeueSong() : null; break; case nameof(IsAllShuffle): IsAllShuffle = queue.DequeueBool(); break; case nameof(IsOnlySearch): IsOnlySearch = queue.DequeueBool(); break; case nameof(IsSearchShuffle): IsSearchShuffle = queue.DequeueBool(); break; case nameof(MediaSources): MediaSources = queue.Any() ? queue.DequeueStrings() : null; break; case nameof(PlayState): PlayState = queue.DequeuePlayState(); break; case nameof(Position): Position = queue.DequeueTimeSpan(); break; case nameof(SearchKey): SearchKey = queue.Any() ? queue.DequeueString() : null; break; case nameof(Volume): Volume = queue.DequeueFloat(); break; default: context.AcceptPublish = false; break; } } catch (Exception e) { context.AcceptPublish = false; try { MqttApplicationMessage message = new MqttApplicationMessage() { Topic = "Debug", Payload = Encoding.UTF8.GetBytes(Utils.GetTypeMessageAndStack(e)), QualityOfServiceLevel = MqttQualityOfServiceLevel.AtLeastOnce, Retain = true }; server.PublishAsync(message); } catch { } } messageInterceptingTopics.Remove(context.ApplicationMessage.Topic); }