From cac41f291bf9a084ba09056aaad5df567ec3d3cb Mon Sep 17 00:00:00 2001 From: Haesu Gwon Date: Tue, 2 Jan 2024 10:17:58 +0900 Subject: [PATCH] [MediaController] Add new API to check Response request (#5672) * [MediaController] Add new API to check Response request --- .../MediaController/MediaControlCommand.cs | 44 ++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaControlCommand.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaControlCommand.cs index 39ec1528b..7c4f14cb3 100644 --- a/src/Tizen.Multimedia.Remoting/MediaController/MediaControlCommand.cs +++ b/src/Tizen.Multimedia.Remoting/MediaController/MediaControlCommand.cs @@ -17,6 +17,7 @@ using Tizen.Applications; using System; using System.Collections.Generic; +using System.ComponentModel; using NativeClient = Interop.MediaControllerClient; using NativeServer = Interop.MediaControllerServer; using NativeClientHandle = Interop.MediaControllerClientHandle; @@ -59,10 +60,33 @@ namespace Tizen.Multimedia.Remoting /// The request Id for each command. internal void SetResponseInformation(string receiverId, string requestId) { - ReceiverId = receiverId ?? throw new ArgumentNullException(nameof(receiverId)); ; - _requestId = requestId ?? throw new ArgumentNullException(nameof(requestId)); ; + ReceiverId = receiverId ?? throw new ArgumentNullException(nameof(receiverId)); + _requestId = requestId; + + if (_requestId == null) + { + Log.Info(GetType().FullName, "request_id is null. Response() should not be called."); + } } + /// + /// Indicates if the response is needed. + /// + /// If false, the receiver should not respond to the received command. + /// 12 + public bool IsResponseNeeded => NeedToResponse; + + /// + /// Indicates if the response is needed. + /// + /// + /// This internal API is retained for backward compatibility but is not recommended for new development. + /// Please use instead.
+ /// If false, the receiver should not respond to the received command. + ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public bool NeedToResponse => _requestId != null; + /// /// Requests command to server. /// @@ -83,13 +107,18 @@ namespace Tizen.Multimedia.Remoting protected virtual void OnResponseCompleted() { } /// - /// Responses command to the client. + /// Responds to the clients command. /// /// The server handle. /// The result of each command. /// The extra data. internal void Response(IntPtr serverHandle, int result, Bundle bundle) { + if (NeedToResponse == false) + { + throw new InvalidOperationException("The receiver should not call this, if NeedToResponse is false."); + } + try { if (bundle != null) @@ -114,13 +143,18 @@ namespace Tizen.Multimedia.Remoting } /// - /// Responses command to the server. + /// Responds to the clients command. /// /// The client handle. /// The result of each command. /// The extra data. internal void Response(NativeClientHandle clientHandle, int result, Bundle bundle) { + if (NeedToResponse == false) + { + throw new InvalidOperationException("The receiver should not call this, if NeedToResponse is false."); + } + try { if (bundle != null) @@ -645,7 +679,7 @@ namespace Tizen.Multimedia.Remoting NativeClient.CreateSearchHandle(out _searchHandle).ThrowIfError("Failed to create search handle."); try - { + { if (condition.Bundle != null) { NativeClient.SetSearchConditionBundle(_searchHandle, condition.ContentType, condition.Category, -- 2.34.1