res, &err);
if (reply == nullptr) {
LOGE("No reply. err(%s)", err ? err->message : "Unknown");
- watcher->OnPortRejected(broker->watch_appid_);
+ watcher->OnPortDisconnected(broker->watch_appid_, broker->watch_port_name_);
g_error_free(err);
return;
}
GVariant* reply_body = g_dbus_message_get_body(reply);
if (reply_body == nullptr) {
LOGE("g_dbus_message_get_body() is failed");
- watcher->OnPortRejected(broker->watch_appid_);
+ watcher->OnPortDisconnected(broker->watch_appid_, broker->watch_port_name_);
g_object_unref(reply);
return;
}
virtual void OnPortRejected(const std::string& appid) = 0;
virtual void OnPortConnected(const std::string& appid,
const std::string& port_name) = 0;
+ virtual void OnPortDisconnected(const std::string& appid,
+ const std::string& port_name) = 0;
};
explicit FdBroker(bool mock = false) : mock_(mock) {}
if (listener_ == nullptr)
return;
- int fds[2] = { 0, };
- int r = fd_broker_.Send(appid, port_name, &fds);
+ fds_[0] = 0;
+ fds_[1] = 0;
+ int r = fd_broker_.Send(appid, port_name, &fds_);
if (r <= 0) {
IEventListener* listener = listener_;
listener_ = nullptr;
return;
}
- LOGW("[__OnPortAppeared__] fds[0]: %d, fds[1]: %d", fds[0], fds[1]);
- main_port_.reset(new ProxyPort(this, fds[0], appid, false));
- delegate_port_.reset(new ProxyPort(this, fds[1], appid));
+ LOGW("[__OnPortAppeared__] fds[0]: %d, fds[1]: %d", fds_[0], fds_[1]);
}
void Proxy::OnPortVanished(const std::string& appid,
LOGW("[__OnPortConnected__] endpoint(%s), port_name(%s)",
appid.c_str(), port_name.c_str());
+ main_port_.reset(new ProxyPort(this, fds_[0], appid, false));
+ delegate_port_.reset(new ProxyPort(this, fds_[1], appid));
listener_->OnConnected(appid, main_port_.get());
}
+void Proxy::OnPortDisconnected(const std::string& appid,
+ const std::string& port_name) {
+ LOGW("[__OnPortDisconnected__] endporint(%s), port_name(%s)",
+ appid.c_str(), port_name.c_str());
+
+ IEventListener* listener = listener_;
+ listener_ = nullptr;
+ listener->OnDisconnected(appid);
+}
+
int Proxy::Connect(std::string appid, std::string port_name,
IEventListener* ev) {
if (ev == nullptr)
void OnPortRejected(const std::string& appid) override;
void OnPortConnected(const std::string& appid,
const std::string& port_name) override;
+ void OnPortDisconnected(const std::string& appid,
+ const std::string& port_name) override;
private:
std::string port_name_;
IEventListener* listener_ = nullptr;
FdBroker fd_broker_;
std::string target_appid_;
+ int fds_[2];
};
} // namespace internal