From 016be514c1b03022e4bc6b7b722f2bf2c833c1f7 Mon Sep 17 00:00:00 2001 From: Haesu Gwon Date: Mon, 30 Oct 2023 12:21:10 +0900 Subject: [PATCH] [MediaController] Add new API to check Response request --- .../MediaController/MediaControlCommand.cs | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaControlCommand.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaControlCommand.cs index 39ec1528bda..f7d4e6cd269 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,22 @@ internal void SetRequestInformation(string receiverId) /// 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."); + } } + /// + /// Gets the status of response. + /// + /// If false, the receiver should not response for the received command. + /// 12 + public bool NeedToResponse => _requestId != null; + /// /// Requests command to server. /// @@ -90,6 +103,11 @@ protected virtual void OnResponseCompleted() { } /// 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) @@ -121,6 +139,11 @@ internal void Response(IntPtr serverHandle, int result, Bundle bundle) /// 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 +668,7 @@ public SearchCommand(MediaControlSearchCondition condition) NativeClient.CreateSearchHandle(out _searchHandle).ThrowIfError("Failed to create search handle."); try - { + { if (condition.Bundle != null) { NativeClient.SetSearchConditionBundle(_searchHandle, condition.ContentType, condition.Category,