Remove ClientPeerInfo class 28/272028/2
authorSangyoon Jang <jeremy.jang@samsung.com>
Wed, 23 Feb 2022 07:11:03 +0000 (16:11 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Mon, 29 Aug 2022 05:51:32 +0000 (14:51 +0900)
Change-Id: I3680afb36655a0a566662453f7b3251be9629993
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
cion/channel/client_channel.cc
cion/channel/client_channel_implementation.hh
cion/channel/client_peer_info.cc [deleted file]
cion/channel/client_peer_info.hh [deleted file]
cion/common/peer_info.cc
cion/common/peer_info.hh

index f63843fc90cf203398d36b777d3ae2988d64a59d..79c7fefc14f5bb09f0d4576016df75165289101e 100644 (file)
@@ -75,10 +75,11 @@ ClientChannel::Impl::Impl(ClientChannel* parent, std::string service_name,
 }
 
 std::shared_ptr<VineClientDp> ClientChannel::Impl::PopDp(VineDpPtr dp) {
-  for (std::shared_ptr<VineClientDp> i : dp_list_) {
-    if (*i == *dp) {
-      dp_list_.remove(i);
-      return i;
+  for (auto it = dp_map_.begin(); it != dp_map_.end(); it++ ) {
+    if (*(it->first) == *dp) {
+      auto pop_dp = it->first;
+      dp_map_.erase(it);
+      return std::dynamic_pointer_cast<VineClientDp>(pop_dp);
     }
   }
   return nullptr;
@@ -88,11 +89,13 @@ ClientChannel::Impl::~Impl() {
   StopDiscovery();
   discoverer_.reset();
   session_.reset();
-  for (const auto& dp : dp_list_) {
-    dp->Dispose();
+  for (const auto& it : dp_map_) {
+    (it.first)->Dispose();
+  }
+  if (peer_) {
+    peer_sync_dp_ = nullptr;
+    peer_dp_ = nullptr;
   }
-  if (connected_peer_)
-    connected_peer_->Dispose();
 }
 
 void ClientChannel::Impl::SendPeerInfo(PeerInfo* peerinfo) {
@@ -104,13 +107,18 @@ void ClientChannel::Impl::SendPeerInfo(PeerInfo* peerinfo) {
 }
 
 void ClientChannel::Impl::Send(cmd::CionCmd cmd, IPayload* data) {
-  if (connected_peer_ == nullptr) {
+  if (peer_ == nullptr) {
     LOG(ERROR) << "No connection to send";
     THROW(error::CION_ERROR_INVALID_OPERATION);
   }
 
   auto dplist = std::make_shared<std::list<std::shared_ptr<VineDp>>>();
-  dplist->push_back(connected_peer_->GetVineClientDp());
+  dplist->push_back(peer_dp_);
+
+  if (peer_dp_)
+    LOG(ERROR) << "peer dp exist";
+  else
+    LOG(ERROR) << "peer dp does not exist";
 
   LOG(INFO) << "send CMD " << cmd;
   AsyncSender as;
@@ -120,7 +128,7 @@ void ClientChannel::Impl::Send(cmd::CionCmd cmd, IPayload* data) {
 void ClientChannel::Impl::Send(cmd::CionCmd cmd,
     const std::vector<uint8_t>& raw, VineDpPtr dp) {
   LOG(INFO) << "send uint& CMD " << cmd;
-  if (connected_peer_ == nullptr) {
+  if (peer_ == nullptr) {
     LOG(ERROR) << "No connection to send";
     THROW(error::CION_ERROR_INVALID_OPERATION);
   }
@@ -129,7 +137,7 @@ void ClientChannel::Impl::Send(cmd::CionCmd cmd,
   if (dp)
     client_dp = dp;
   else
-    client_dp = connected_peer_->GetVineClientDp();
+    client_dp = peer_dp_;
   tizen_base::Parcel parcel;
   parcel.WriteUInt32(cmd);
   parcel.WriteUInt32(raw.size());
@@ -153,7 +161,7 @@ std::vector<char> ClientChannel::Impl::SendData(std::vector<char> data,
     int timeout) {
   std::lock_guard<std::mutex> lock(mutex_);
 
-  if (!connected_peer_ || !is_connected_) {
+  if (!peer_ || !is_connected_) {
     LOG(ERROR) << "No connection established";
     THROW(error::CION_ERROR_INVALID_OPERATION);
   }
@@ -164,7 +172,8 @@ std::vector<char> ClientChannel::Impl::SendData(std::vector<char> data,
   LOG(WARNING) << "send data seq id : " << sequence_id_;
 
   auto *d = reinterpret_cast<std::vector<uint8_t>*>(&data);
-  Send(cmd::DataSync, *d, connected_peer_->GetVineClientSyncDp());
+  // Send(cmd::DataSync, *d, connected_peer_->GetVineClientSyncDp());
+  Send(cmd::DataSync, *d, peer_sync_dp_);
   reply_queue_.WaitAndPopFor(ret, timeout);
 
   if (ret.empty()) {
@@ -181,13 +190,13 @@ void ClientChannel::Impl::SendPayloadAsync(IPayload* data,
   if (data == nullptr)
     THROW(error::CION_ERROR_INVALID_PARAMETER);
 
-  if (!connected_peer_ || !is_connected_) {
+  if (!peer_ || !is_connected_) {
     LOG(ERROR) << "No connection established";
     THROW(error::CION_ERROR_INVALID_OPERATION);
   }
 
   async_result_manager_->AddAsyncResultToWaitList(
-      connected_peer_, data->GetID(),
+      peer_, data->GetID(),
       PayloadAsyncResult::ResultCode::Pending, func);
 
   Send(cmd::PayloadAsync, data);
@@ -198,34 +207,36 @@ void ClientChannel::Impl::Disconnect(VineDpPtr dp) {
   if (!dp)
     return;
 
-  if (connected_peer_ != nullptr && connected_peer_->GetVineClientDp()) {
+  if (peer_ != nullptr && peer_dp_) {
     LOG(INFO) << "Compare " << dp->GetRawDp() << " : "
-              << connected_peer_->GetVineClientDp()->GetRawDp();
-    if (*connected_peer_->GetVineClientDp() == *dp)
-      parent_->OnDisconnected(connected_peer_);
+              << peer_dp_->GetRawDp();
+    if (*peer_dp_ == *dp)
+      parent_->OnDisconnected(peer_);
   }
   PopDp(dp);
 }
 
 std::shared_ptr<VineClientDp> ClientChannel::Impl::GetDp(
     std::string ip, int port) {
-  for (std::shared_ptr<VineClientDp> i : dp_list_) {
-    if (i->GetPort() == port && i->GetIp() == ip)
-      return i;
+  for (auto& it : dp_map_) {
+    auto dp = std::dynamic_pointer_cast<VineClientDp>(it.first);
+    if (dp->GetPort() == port && dp->GetIp() == ip)
+      return dp;
   }
   LOG(WARNING) << "Cannot find dp [ip : " << ip << ", port : "
       << port << "]";
   return nullptr;
 }
 
-std::shared_ptr<VineClientDp> ClientChannel::Impl::GetDp(
-    std::shared_ptr<VineDp> dp) {
-  for (std::shared_ptr<VineClientDp> i : dp_list_) {
-    if (*i == *dp)
-      return i;
+std::shared_ptr<VineClientDp> ClientChannel::Impl::GetPeerDp(std::shared_ptr<PeerInfo> peer) {
+  std::shared_ptr<VineClientDp> client_dp = nullptr;
+  for (auto& it : dp_map_) {
+    if (*it.second == *peer) {
+      client_dp = std::dynamic_pointer_cast<VineClientDp>(it.first);
+      break;
+    }
   }
-  LOG(WARNING) << "Cannot find dp  : " << dp->GetRawDp();
-  return nullptr;
+  return client_dp;
 }
 
 void ClientChannel::Impl::TrySyncReply(std::vector<unsigned char> data) {
@@ -287,15 +298,18 @@ void ClientChannel::Impl::StopDiscovery() {
 }
 
 void ClientChannel::Impl::TryConnect(std::shared_ptr<PeerInfo> peer) {
-  if (connected_peer_) {
+  if (peer_) {
     LOG(ERROR) << "There is a ongoing connection!";
     return;
   }
 
   LOG(INFO) << "TryConnect";
-  std::shared_ptr<ClientPeerInfo> cpeer =
-      std::dynamic_pointer_cast<ClientPeerInfo>(peer);
-  connected_peer_ = cpeer;
+  peer_ = peer;
+  std::shared_ptr<VineClientDp> client_dp = GetPeerDp(peer);
+  if (!client_dp) {
+    LOG(ERROR) << "Cannot find dp for " << peer->GetUUID();
+    return;
+  }
 
   std::string appid = peer->GetAppID();
   if (peer == ondemand_list_[appid]) {
@@ -313,8 +327,7 @@ void ClientChannel::Impl::TryConnect(std::shared_ptr<PeerInfo> peer) {
     parcel.Write(payload_data_raw.data(), payload_data_raw.size());
 
     try {
-      Send(cmd::OndemandLaunch, parcel.GetRaw(),
-          connected_peer_->GetVineClientDp());
+      Send(cmd::OndemandLaunch, parcel.GetRaw(), GetPeerDp(peer_));
     } catch (const Exception& e) {
       LOG(ERROR) << "Failed to try connect: " << e.what();
       throw e;
@@ -323,7 +336,7 @@ void ClientChannel::Impl::TryConnect(std::shared_ptr<PeerInfo> peer) {
     return;
   }
 
-  std::shared_ptr<VineClientDp> client_dp = connected_peer_->GetVineClientDp();
+  // std::shared_ptr<VineClientDp> client_dp = connected_peer_->GetVineClientDp();
   client_dp->Close();
   client_dp->SetDpOpenedEventHandler(this);
   client_dp->SetDpReceivedEventHandler(this);
@@ -333,15 +346,15 @@ void ClientChannel::Impl::TryConnect(std::shared_ptr<PeerInfo> peer) {
 }
 
 void ClientChannel::Impl::Disconnect() {
-  if (connected_peer_ == nullptr) {
+  if (peer_ == nullptr) {
     LOG(ERROR) << "no connection";
     return;
   }
 
   is_connected_ = false;
-  Disconnect(connected_peer_->GetVineClientSyncDp());
-  Disconnect(connected_peer_->GetVineClientDp());
-  connected_peer_ = nullptr;
+  Disconnect(peer_dp_);
+  Disconnect(peer_sync_dp_);
+  peer_ = nullptr;
 }
 
 void ClientChannel::Impl::OnServiceDiscovered(VineService service,
@@ -362,7 +375,7 @@ void ClientChannel::Impl::OnServiceDiscovered(VineService service,
     return;
   }
 
-  dp_list_.push_back(cdp);
+  dp_map_.emplace(cdp, nullptr);
   cdp->SetDpReceivedEventHandler(this);
   cdp->SetDpTerminatedEventHandler(this);
   if (!security_.IsEmpty()) {
@@ -378,18 +391,18 @@ void ClientChannel::Impl::OnServiceDiscovered(VineService service,
 }
 
 void ClientChannel::Impl::OnDpOpened(VineDpPtr dp, int result) {
-  if (connected_peer_) {
+  if (peer_) {
     LOG(INFO) << "OnDpOpened : SendPeerInfo " << dp->GetRawDp();
     try {
       Send(cmd::CionCmd::PeerInfo, my_peer_info_->Serialize(), dp);
-      auto cdp = connected_peer_->GetVineClientDp();
+      auto cdp = GetPeerDp(peer_);
       if (cdp && cdp->GetRawDp() != dp->GetRawDp()) {
         // Sync dp is opened, invoke OnConnectionResultCallback at idle
         idle_invoker_.InvokeAtIdle(
           [this]() -> void {
             ConnectionResult res(ConnectionResult::ConnectionStatus::OK);
             is_connected_ = true;
-            parent_->OnConnectionResult(connected_peer_, res);
+            parent_->OnConnectionResult(peer_, res);
           });
       }
     } catch (const Exception& e) {
@@ -427,20 +440,20 @@ void ClientChannel::Impl::OnDpReceived(
             parcel->ReadUInt32(&size);
             std::vector<unsigned char> peerinfo_data(size, 0);
             parcel->Read(peerinfo_data.data(), peerinfo_data.size());
-            auto peer_dp = GetDp(dp);
-            std::shared_ptr<ClientPeerInfo> discovered_info =
-                std::make_shared<ClientPeerInfo>(peerinfo_data.data(),
-                    peerinfo_data.size(), GetDp(dp));
+            std::shared_ptr<PeerInfo> discovered_info =
+                std::make_shared<PeerInfo>(peerinfo_data.data(),
+                    peerinfo_data.size());
+            if (dp_map_.count(dp))
+              dp_map_[dp] = discovered_info;
 
-            auto peer = connected_peer_;
+            auto peer = peer_;
             if (peer && peer->GetDeviceID() == discovered_info->GetDeviceID() &&
                 peer->GetAppID() == discovered_info->GetAppID()) {
               if (ondemand_list_[discovered_info->GetAppID()]) {
                 LOG(INFO) << "Ondemand Launched " << discovered_info->GetAppID();
 
-                connected_peer_ = discovered_info;
-                std::shared_ptr<VineClientDp> client_dp =
-                    connected_peer_->GetVineClientDp();
+                peer_ = discovered_info;
+                std::shared_ptr<VineClientDp> client_dp = GetPeerDp(peer_);
                 client_dp->Close();
                 client_dp->SetDpOpenedEventHandler(this);
                 client_dp->SetDpReceivedEventHandler(this);
@@ -450,8 +463,7 @@ void ClientChannel::Impl::OnDpReceived(
                 ondemand_list_.erase(discovered_info->GetAppID());
 
                 ConnectionResult result(ConnectionResult::ConnectionStatus::OK);
-                parent_->OnConnectionResult(std::dynamic_pointer_cast<PeerInfo>(
-                    connected_peer_), result);
+                parent_->OnConnectionResult(peer_, result);
 
                 return;
               }
@@ -459,25 +471,27 @@ void ClientChannel::Impl::OnDpReceived(
               return;
             }
 
-            if (!peer_dp) {
+            if (!dp_map_.count(dp)) {
               LOG(WARNING) << "Ignore sync dp";
               return;
             }
 
             LOG(INFO) << "On discovered " << discovered_info->GetAppID();
 
-            parent_->OnDiscovered(
-                std::dynamic_pointer_cast<PeerInfo>(discovered_info));
+            parent_->OnDiscovered(discovered_info);
             return;
           }
           case cmd::Accept: {
             LOG(INFO) << "Connection request accepted";
-            auto peer = connected_peer_;
-            auto client_dp = peer->GetVineClientDp();
+            // auto peer = connected_peer_;
+            auto client_dp = GetPeerDp(peer_);
+            peer_dp_ = client_dp;
+            // auto client_dp = peer->GetVineClientDp();
             auto client_sync_dp = std::make_shared<VineClientDp>(
                 session_, client_dp->GetIp(),
                 client_dp->GetRemotePort());
-            peer->SetVineClientSyncDp(client_sync_dp);
+            // peer->SetVineClientSyncDp(client_sync_dp);
+            peer_sync_dp_ = client_sync_dp;
             client_sync_dp->SetDpOpenedEventHandler(this);
             client_sync_dp->SetDpReceivedEventHandler(this);
             client_sync_dp->SetDpTerminatedEventHandler(this);
@@ -499,9 +513,8 @@ void ClientChannel::Impl::OnDpReceived(
 
             ConnectionResult result(
                 ConnectionResult::ConnectionStatus::Rejected, reason);
-            parent_->OnConnectionResult(std::dynamic_pointer_cast<PeerInfo>(
-                connected_peer_), result);
-            connected_peer_ = nullptr;
+            parent_->OnConnectionResult(peer_, result);
+            peer_ = nullptr;
             break;
           }
           case cmd::AsyncResult: {
@@ -510,15 +523,14 @@ void ClientChannel::Impl::OnDpReceived(
             parcel->Read(res_data.data(), res_data.size());
             std::shared_ptr<PayloadAsyncResult> result =
                 std::make_shared<PayloadAsyncResult>(std::move(res_data));
-            result->SetPeerInfo(connected_peer_);
+            result->SetPeerInfo(peer_);
 
             async_result_manager_->InvokeResultCallback(result);
             break;
           }
           case cmd::PayloadAsync: {
             PayloadManager pm(parent_);
-            pm.Process(parcel, dp,
-                my_peer_info_, connected_peer_);
+            pm.Process(parcel, dp, my_peer_info_, peer_);
             break;
           }
           case cmd::OndemandDaemonReply: {
@@ -568,9 +580,9 @@ void ClientChannel::Impl::OnDpReceived(
               list_parcel->ReadUInt32(&peer_data_size);
               std::vector<unsigned char> peerinfo_data(peer_data_size, 0);
               list_parcel->Read(peerinfo_data.data(), peerinfo_data.size());
-              std::shared_ptr<ClientPeerInfo> discovered_info =
-                  std::make_shared<ClientPeerInfo>(peerinfo_data.data(),
-                      peerinfo_data.size(), GetDp(dp));
+              std::shared_ptr<PeerInfo> discovered_info =
+                  std::make_shared<PeerInfo>(peerinfo_data.data(),
+                      peerinfo_data.size());
               ondemand_list_[discovered_info->GetAppID()] =
                   discovered_info;
               LOG(INFO) << "On discovered " << discovered_info->GetAppID();
@@ -647,7 +659,7 @@ void ClientChannel::SendPayloadAsync(IPayload* data,
 }
 
 std::shared_ptr<PeerInfo> ClientChannel::GetPeerInfo() {
-  return impl_->connected_peer_;
+  return impl_->peer_;
 }
 
 std::string ClientChannel::GetServiceName() {
index 0f0422397686a139e5c3a2f86b2d6df0dd359228..67e540806787bfb608261e2df605938d9cdde8a1 100644 (file)
@@ -26,7 +26,6 @@
 #include <map>
 
 #include "cion/channel/client_channel.hh"
-#include "cion/channel/client_peer_info.hh"
 #include "cion/channel/shared_queue.hh"
 #include "cion/channel/channel_job.hh"
 #include "cion/channel/idle_invoker.hh"
@@ -35,6 +34,7 @@
 #include "cion/channel/payload_async_result_manager.hh"
 #include "cion/channel/payload_manager.hh"
 
+#include "cion/vine/vine_client_dp.hh"
 #include "cion/vine/vine_session.hh"
 #include "cion/vine/vine_discoverer.hh"
 #include "cion/vine/vine_interfaces.hh"
@@ -57,7 +57,7 @@ class ClientChannel::Impl : public IVineServiceBrowser, IVineDpOpenedEventHandle
   std::shared_ptr<VineClientDp> PopDp(VineDpPtr dp);
   void Disconnect(VineDpPtr dp);
   std::shared_ptr<VineClientDp> GetDp(std::string ip, int port);
-  std::shared_ptr<VineClientDp> GetDp(std::shared_ptr<VineDp> dp);
+  std::shared_ptr<VineClientDp> GetPeerDp(std::shared_ptr<PeerInfo> peer);
   void TrySyncReply(std::vector<unsigned char> data);
   void TryDiscovery();
   void StopDiscovery();
@@ -76,14 +76,18 @@ class ClientChannel::Impl : public IVineServiceBrowser, IVineDpOpenedEventHandle
   std::string service_name_;
   int channel_id_;
   std::shared_ptr<PeerInfo> my_peer_info_;
-  std::shared_ptr<ClientPeerInfo> connected_peer_;
-  std::list<std::shared_ptr<VineClientDp>> dp_list_;
+
+  std::map<std::shared_ptr<VineDp>, std::shared_ptr<PeerInfo>> dp_map_;
+  std::shared_ptr<PeerInfo> peer_;
+  std::shared_ptr<VineDp> peer_dp_;
+  std::shared_ptr<VineDp> peer_sync_dp_;
+
   std::shared_ptr<VineSession> session_;
   bool is_discovering_ = false;
   SharedQueue<std::vector<char>> reply_queue_;
   std::shared_ptr<VineDiscoverer> discoverer_ = nullptr;
   std::shared_ptr<PayloadAsyncResultManager> async_result_manager_ = nullptr;
-  std::map<std::string, std::shared_ptr<ClientPeerInfo>> ondemand_list_;
+  std::map<std::string, std::shared_ptr<PeerInfo>> ondemand_list_;
   bool is_timeover_ = false;
   bool is_connected_ = false;
   unsigned int sequence_id_ = 0;
diff --git a/cion/channel/client_peer_info.cc b/cion/channel/client_peer_info.cc
deleted file mode 100644 (file)
index d6af383..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "cion/channel/client_peer_info.hh"
-#include "cion/common/util/logging.hh"
-
-namespace cion {
-
-ClientPeerInfo::ClientPeerInfo() : PeerInfo() {
-  LOG(INFO) << "client peer info " << GetUUID();
-}
-
-ClientPeerInfo::ClientPeerInfo(const void* buf,
-    uint32_t size, std::shared_ptr<VineClientDp> vine_dp)
-  : PeerInfo(buf, size), vine_client_dp_(vine_dp) {
-  LOG(INFO) << "create client peer info with buf " << GetUUID();
-}
-
-ClientPeerInfo::ClientPeerInfo(const ClientPeerInfo& peerinfo)
-  : PeerInfo(peerinfo), vine_client_dp_(peerinfo.vine_client_dp_) {
-}
-
-ClientPeerInfo::~ClientPeerInfo() {
-  LOG(WARNING) << "destroy client peer info " << GetUUID();
-}
-
-std::shared_ptr<VineClientDp> ClientPeerInfo::GetVineClientDp() {
-  return vine_client_dp_;
-}
-
-std::shared_ptr<VineClientDp> ClientPeerInfo::GetVineClientSyncDp() {
-  return vine_client_sync_dp_;
-}
-
-void ClientPeerInfo::SetVineClientSyncDp(std::shared_ptr<VineClientDp> dp) {
-  vine_client_sync_dp_ = std::move(dp);
-}
-
-// TODO(jeremy.jang): PeerInfo should not have dp itself.
-void ClientPeerInfo::Dispose() {
-  vine_client_dp_ = nullptr;
-  vine_client_sync_dp_ = nullptr;
-}
-
-}  // namespace cion
diff --git a/cion/channel/client_peer_info.hh b/cion/channel/client_peer_info.hh
deleted file mode 100644 (file)
index e96b16c..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CION_CHANNEL_CLIENT_PEER_INFO_HH_
-#define CION_CHANNEL_CLIENT_PEER_INFO_HH_
-
-#include <parcel/parcel.hh>
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "cion/common/peer_info.hh"
-#include "cion/vine/vine_client_dp.hh"
-
-namespace cion {
-
-class ClientPeerInfo : public PeerInfo {
- public:
-  ClientPeerInfo();
-  ClientPeerInfo(const void* buf,
-      uint32_t size, std::shared_ptr<VineClientDp> dp_info);
-  ClientPeerInfo(const ClientPeerInfo& peerinfo);
-  ~ClientPeerInfo();
-
-  std::shared_ptr<VineClientDp> GetVineClientDp();
-  std::shared_ptr<VineClientDp> GetVineClientSyncDp();
-  void SetVineClientSyncDp(std::shared_ptr<VineClientDp> dp);
-  void Dispose();
-
- private:
-  std::shared_ptr<VineClientDp> vine_client_dp_;
-  std::shared_ptr<VineClientDp> vine_client_sync_dp_;
-};
-
-}  // namespace cion
-
-#endif  // CION_CHANNEL_CLIENT_PEER_INFO_HH_
index 43b2608b9280c9a4c4549472fc571574e421ef2c..ee62fa00b62895b293d20e4503362a09469a9659 100644 (file)
@@ -121,6 +121,16 @@ PeerInfo::PeerInfo(const PeerInfo& peerinfo) {
 PeerInfo::~PeerInfo() {
 }
 
+bool PeerInfo::operator==(const PeerInfo& other) {
+  return device_id_ == other.GetDeviceID() && uuid_ == other.GetUUID() &&
+      app_id_ == other.GetAppID();
+}
+
+bool PeerInfo::operator!=(const PeerInfo& other) {
+  return device_id_ != other.GetDeviceID() || uuid_ != other.GetUUID() ||
+      app_id_ != other.GetAppID();
+}
+
 void PeerInfo::WriteToParcel(tizen_base::Parcel* parcel) const {
   parcel->WriteString(device_id_);
   parcel->WriteString(device_name_);
index a194d339ccec4ba78b5904da687bce2a511a0282..88b45dbe868b5796b6721a63947dab3451912a8c 100644 (file)
@@ -37,7 +37,8 @@ class PeerInfo : private tizen_base::Parcelable {
   explicit PeerInfo(const void* buf, uint32_t size);
   PeerInfo(const PeerInfo& peerinfo);
   ~PeerInfo();
-
+  bool operator==(const PeerInfo& other);
+  bool operator!=(const PeerInfo& other);
   std::string GetDeviceID() const;
   std::string GetDeviceName() const;
   std::string GetDevicePlatform() const;