/// <summary> /// 暂停下载任务 /// </summary> /// <param name="gid"></param> /// <returns></returns> public async Task <string> Pause(string gid) { var res = new PauseResponse(await _client.SendRequestAsync(new PauseRequest { GID = gid })); return(res?.GID); }
public AResponse CreateResponse(string responseData) { AResponse response = null; try { // validate length if (responseData.Length < Protocol.Instance.HeaderLength) { throw new ParserException("invalid responseData length"); } // get the header string header = responseData.Substring(0, (int)Protocol.Instance.HeaderLength); switch (_messageHeaderMapper[header]) { case MessageType.DisplayDevicesInfo: response = new DisplayDeviceInfoResponse(); break; case MessageType.Pause: response = new PauseResponse(); break; case MessageType.Play: response = new PlayResponse(); break; case MessageType.Resume: response = new ResumeResponse(); break; case MessageType.Seek: response = new SeekResponse(); break; case MessageType.SetImage: response = new SetImageResponse(); break; case MessageType.SetText: response = new SetTextResponse(); break; case MessageType.RemoveAddon: response = new RemoveAddonResponse(); break; case MessageType.Stop: response = new StopResponse(); break; case MessageType.Termination: response = new TerminationResponse(); break; case MessageType.VideoLayout: response = new VideoLayoutResponse(); break; case MessageType.Volume: response = new VolumeResponse(); break; case MessageType.WindowLayout: response = new WindowLayoutResponse(); break; case MessageType.SoundFx: response = new SoundFxResponse(); break; case MessageType.Sound3d: response = new Sound3dResponse(); break; case MessageType.MidiProperties: response = new MidiPropertiesResponse(); break; case MessageType.MidiOutputPortInfo: response = new MidiOutputPortInfoResponse(); break; case MessageType.SetMidiOutputPort: response = new SetMidiOutputPortResponse(); break; case MessageType.SetDls: response = new SetDlsResponse(); break; case MessageType.SetFrequency: response = new SetFrequencyResponse(); break; case MessageType.SetRate: response = new SetRateResponse(); break; case MessageType.SetPlayerType: response = new SetPlayerTypeResponse(); break; default: throw new ParserException("invalid message header"); } response.ParseFromString(responseData); } catch (System.Exception e) { throw e; } return(response); }