Implement StopDiscovery
authorhyunho <hhstark.kang@samsung.com>
Mon, 8 Mar 2021 07:57:59 +0000 (16:57 +0900)
committer강현호/Tizen Platform Lab(SR)/Engineer/삼성전자 <hhstark.kang@samsung.com>
Tue, 9 Mar 2021 02:50:02 +0000 (11:50 +0900)
Signed-off-by: hyunho <hhstark.kang@samsung.com>
cion/vine_manager/vine_manager.cc
cion/vine_manager/vine_manager.hh

index c9237efa1429dfb1ea90198b4e403435a0dd573e..43455977da118637f33d8bcba19beb239d00e64d 100644 (file)
@@ -190,6 +190,19 @@ void VineManager::SetClientRecvCallback(vine_dp_h client_dp, void* user_data) {
   }, user_data);
 }
 
+bool VineManager::StopDiscovery(int channel_id) {
+  std::shared_ptr<SessionInfo> info = GetSessionInfo(channel_id);
+  if (info->IsDiscovering()) {
+    LOGE("Already discovering (%d)", channel_id);
+    return false;
+  }
+
+  vine_session_unset_discovered_cb(info->GetSession());
+  vine_session_stop_discovery(info->GetSession());
+  info->SetIsDiscovering(false);
+  return true;
+}
+
 bool VineManager::Discovery(int channel_id) {
   std::shared_ptr<SessionInfo> info = GetSessionInfo(channel_id);
   if (info->IsDiscovering()) {
@@ -647,6 +660,7 @@ void VineManager::OperateChannel(int channel_id,
         Discovery(channel_id);
         break;
       case IControlInfo::ControlType::StopDiscovery :
+        StopDiscovery(channel_id);
         break;
     }
   } else if (info->GetChannelType() == IControlInfo::ChannelType::Broadcast) {
index 95c7a655026554eca3fff80a9641eeb3dcd81989..32c19cf6e0d397726aa970747ebb0090db4b8b1d 100644 (file)
@@ -80,6 +80,7 @@ class EXPORT_API VineManager {
       std::shared_ptr<PeerInfo> peer_info);
   void RegisterService(std::shared_ptr<SessionInfo> info, int port);
   bool Discovery(int channel_id);
+  bool StopDiscovery(int channel_id);
   void OpenServer(int channel_id);
   channel::IEventObserver* GetObserver(int channel_id);
   std::shared_ptr<SessionInfo> GetSessionInfo(int channel_id);