Example #1
0
 public async Task NotifyTrackChange(TrackEvent track)
 {
     if (socket != null && socket.State == WebSocketState.Open)
     {
         try
         {
             string json = JsonConvert.SerializeObject(track);
             var    buff = new ArraySegment <byte>(Encoding.UTF8.GetBytes(json));
             await socket.SendAsync(buff, WebSocketMessageType.Binary, true, CancellationToken.None);
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
         }
     }
 }
Example #2
0
        public async Task SetTrack(TrackEvent track)
        {
            await Task.WhenAll(Listeners.Select(async listener => await listener.NotifyTrackChange(track)));

            CurrentTrack = track;
        }