public void Reset()
        {
            nowPlaying = null;
            currentMedia = null;
            opResult = null;

            httpRequest = null;
            dataMessageReceived = null;
            dataToSend = null;
            messageBytesReceived = 0;
        }
Beispiel #2
0
 /// <summary>
 /// Executes a command with the given parameter string and returns a string return
 /// </summary>
 /// <param name="command">command name string</param>
 /// <param name="param">parameter string</param>
 /// <param name="playlist">now playing playlist, may be null</param>
 /// <param name="result">string</param>
 /// <returns></returns>
 public OpResult Execute(String command, string param, NowPlayingList playlist, MediaItem currentItem)
 {
     command = command.ToLower();
     if (m_commands.ContainsKey(command))
     {
         try
         {
             if (command.Equals("music-cache-status"))
             {
                 OpResult opResult = new OpResult();
                 CacheStatus status = new CacheStatus(this.isCacheBuilding);
                 opResult.StatusCode = OpStatusCode.Json;
                 opResult.ContentText = JsonConvert.SerializeObject(status, Newtonsoft.Json.Formatting.Indented);
                 return opResult;
             }
             else if (m_commands[command] is MusicICommand)
             {
                 //Make sure cache is not being modified before executing any of the music-* commands
                 lock (cacheLock)
                 {
                     return ((MusicICommand)m_commands[command]).Execute(param, playlist, currentItem);
                 }
             }
             else
             {
                 return m_commands[command].Execute(param);
             }
         }
         catch (Exception ex)
         {
             OpResult opResult = new OpResult();
             opResult.StatusCode = OpStatusCode.Exception;
             opResult.StatusText = ex.Message;
             opResult.AppendFormat(ex.Message);
             return opResult;
         }
     }
     else
     {
         return new OpResult(OpStatusCode.BadRequest);
     }
 }