Exemplo n.º 1
0
        /// <summary>
        /// Starts the streaming for the user continously
        /// </summary>
        public static void StartStreaming()
        {
            Guid     guid     = Guid.NewGuid();
            Streamer streamer = new Streamer()
            {
                Context    = System.Web.HttpContext.Current,
                HostName   = HttpContextHelper.GetHostName(),
                StreamDate = DateTime.Now
            };

            //Add headers
            streamer.Context.Response.AddHeader("Content-Type", "audio/mp3");

            //Add it to context pool
            activeContexts.AddOrUpdate(guid, streamer, (k, v) => streamer);

            //Validate the recorder
            ValidateRecorderState();

            //Update the clients about newly joined streamer
            TunerHub.UpdateStreamers(streamer.HostName, ConnectionState.Connected);

            //Keep streaming
            while (streamer.Context.Response.IsClientConnected)
            {
                Thread.Sleep(1000);
            }

            //Delete context from activeContexts since the client is disconnected
            while (!activeContexts.TryRemove(guid, out streamer))
            {
                Thread.Sleep(10);
            }

            //Update the clients about disconnected streamer
            TunerHub.UpdateStreamers(streamer.HostName, ConnectionState.Disconnected);

            //Validate the recorder
            ValidateRecorderState();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Inserts given info to the list
 /// </summary>
 /// <param name="ip">Request ip</param>
 /// <param name="action">Request action</param>
 public static void Insert(ActionLog log)
 {
     lastIPsAndActions.Add(log);
     TunerHub.UpdateLastIPsAndActions(log);
 }
Exemplo n.º 3
0
 private static void ProcessNotificationData(AudioVolumeNotificationData data)
 {
     TunerHub.UpdateSoundLevel((short)Math.Round(data.MasterVolume * 100));
 }