/// <summary> /// Allows the programmer to query the progress of this transfer object. /// </summary> /// <param name="Tag"> /// Miscellaneous, user-provided object for tracking this /// asynchronous call. Can be used as a means to pass a /// user-defined "state object" at invoke-time so that /// the executed callback during results-processing can be /// aware of the component's state at the time of the call. /// </param> /// <param name="callback">the callback to execute when results become available</param> /// <exception cref="ApplicationException"> /// Thrown if the resource object associated with thsi transfer is null. /// Such an exception would indicate that the system has improperly instantiated the transfer object. /// </exception> /// <exception cref="NullReferenceException"> /// Thrown if the transfer object cannot find its media server. /// </exception> public void RequestGetTransferProgress(object Tag, CpMediaDelegates.Delegate_ResultGetTransferProgress callback) { if (this.m_Resource == null) { throw new ApplicationException("Bad Evil. The resource associated with this transfer object is null."); } CpMediaServer server = (CpMediaServer)this.mwr_Server.Target; if (this.mwr_Server.IsAlive == false) { throw new NullReferenceException("The media server object is null. Media server may have disappeared from UPnP network."); } GetTransferProgressRequestTag rtag = new GetTransferProgressRequestTag(); rtag.Tag = Tag; rtag.Callback = callback; server.RequestGetTransferProgress(this.m_TransferID, rtag, new CpContentDirectory.Delegate_OnResult_GetTransferProgress(this.SinkResult_GetTransferProgress)); }
/// <summary> /// This routes execution to the user-provided callback, provided in a call to /// <see cref="ResourceTransfer.RequestGetTransferProgress"/> /// when the results return from <see cref="ResourceTransfer.RequestGetTransferProgress"/>. /// </summary> /// <param name="sender">the <see cref="CpContentDirectory"/> that made the request on the wire</param> /// <param name="TransferID">caller specified ID of the transfer at invoke time</param> /// <param name="TransferStatus">output status for the transfer</param> /// <param name="TransferLength">output progress of the transfer</param> /// <param name="TransferTotal">output expected length of the transfer</param> /// <param name="e">errors reported by media server</param> /// <param name="_Tag"> /// A <see cref="GetTransferProgressRequestTag"/> object that has information about the callback /// and user provided state. /// </param> private void SinkResult_GetTransferProgress(CpContentDirectory sender, System.UInt32 TransferID, CpContentDirectory.Enum_A_ARG_TYPE_TransferStatus TransferStatus, System.String TransferLength, System.String TransferTotal, UPnPInvokeException e, object _Tag) { GetTransferProgressRequestTag rtag = (GetTransferProgressRequestTag)_Tag; if (rtag.Callback != null) { System.Int64 length = -1; System.Int64 total = -1; Exception castError = null; try { System.Int64.Parse(TransferLength); System.Int64.Parse(TransferTotal); } catch (Exception ce) { castError = ce; } rtag.Callback(this, TransferStatus, length, total, rtag.Tag, e, castError); } }
/// <summary> /// Allows the programmer to query the progress of this transfer object. /// </summary> /// <param name="Tag"> /// Miscellaneous, user-provided object for tracking this /// asynchronous call. Can be used as a means to pass a /// user-defined "state object" at invoke-time so that /// the executed callback during results-processing can be /// aware of the component's state at the time of the call. /// </param> /// <param name="callback">the callback to execute when results become available</param> /// <exception cref="ApplicationException"> /// Thrown if the resource object associated with thsi transfer is null. /// Such an exception would indicate that the system has improperly instantiated the transfer object. /// </exception> /// <exception cref="NullReferenceException"> /// Thrown if the transfer object cannot find its media server. /// </exception> public void RequestGetTransferProgress(object Tag, CpMediaDelegates.Delegate_ResultGetTransferProgress callback) { if (this.m_Resource == null) { throw new ApplicationException("Bad Evil. The resource associated with this transfer object is null."); } CpMediaServer server = (CpMediaServer) this.mwr_Server.Target; if(this.mwr_Server.IsAlive == false) { throw new NullReferenceException("The media server object is null. Media server may have disappeared from UPnP network."); } GetTransferProgressRequestTag rtag = new GetTransferProgressRequestTag(); rtag.Tag = Tag; rtag.Callback = callback; server.RequestGetTransferProgress(this.m_TransferID, rtag, new CpContentDirectory.Delegate_OnResult_GetTransferProgress(this.SinkResult_GetTransferProgress)); }