Remove AsyncResp from openHandler
This change, moving the openHandler back to only supporting websocket
disconnects and not 404s.Because AsyncResp is removed from openHandler.
Tested:
Opened KVM in webui-vue and it works.
Signed-off-by: zhanghaicheng <zhanghch05@inspur.com>
Change-Id: I90811f4ab91ad41cb298877f76252dce80932b2b
diff --git a/http/routing.hpp b/http/routing.hpp
index 0a0dc74..abb1d43 100644
--- a/http/routing.hpp
+++ b/http/routing.hpp
@@ -386,9 +386,7 @@
}
protected:
- std::function<void(crow::websocket::Connection&,
- std::shared_ptr<bmcweb::AsyncResp>)>
- openHandler;
+ std::function<void(crow::websocket::Connection&)> openHandler;
std::function<void(crow::websocket::Connection&, const std::string&, bool)>
messageHandler;
std::function<void(crow::websocket::Connection&, const std::string&)>
diff --git a/http/websocket.hpp b/http/websocket.hpp
index 324ffd5..06f35d1 100644
--- a/http/websocket.hpp
+++ b/http/websocket.hpp
@@ -65,8 +65,7 @@
public:
ConnectionImpl(
const crow::Request& reqIn, Adaptor adaptorIn,
- std::function<void(Connection&, std::shared_ptr<bmcweb::AsyncResp>)>
- openHandler,
+ std::function<void(Connection&)> openHandler,
std::function<void(Connection&, const std::string&, bool)>
messageHandler,
std::function<void(Connection&, const std::string&)> closeHandler,
@@ -193,14 +192,11 @@
{
BMCWEB_LOG_DEBUG << "Websocket accepted connection";
- auto asyncResp = std::make_shared<bmcweb::AsyncResp>();
-
- asyncResp->res.result(boost::beast::http::status::ok);
doRead();
if (openHandler)
{
- openHandler(*this, asyncResp);
+ openHandler(*this);
}
}
@@ -280,8 +276,7 @@
std::vector<std::string> outBuffer;
bool doingWrite = false;
- std::function<void(Connection&, std::shared_ptr<bmcweb::AsyncResp>)>
- openHandler;
+ std::function<void(Connection&)> openHandler;
std::function<void(Connection&, const std::string&, bool)> messageHandler;
std::function<void(Connection&, const std::string&)> closeHandler;
std::function<void(Connection&)> errorHandler;
diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp
index a6c86c6..6004194 100644
--- a/include/dbus_monitor.hpp
+++ b/include/dbus_monitor.hpp
@@ -107,8 +107,7 @@
BMCWEB_ROUTE(app, "/subscribe")
.privileges({{"Login"}})
.websocket()
- .onopen([&](crow::websocket::Connection& conn,
- const std::shared_ptr<bmcweb::AsyncResp>&) {
+ .onopen([&](crow::websocket::Connection& conn) {
BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
sessions[&conn] = DbusWebsocketSession();
})
diff --git a/include/kvm_websocket.hpp b/include/kvm_websocket.hpp
index a9dc8ea..46443b9 100644
--- a/include/kvm_websocket.hpp
+++ b/include/kvm_websocket.hpp
@@ -161,8 +161,7 @@
BMCWEB_ROUTE(app, "/kvm/0")
.privileges({{"ConfigureComponents", "ConfigureManager"}})
.websocket()
- .onopen([](crow::websocket::Connection& conn,
- const std::shared_ptr<bmcweb::AsyncResp>&) {
+ .onopen([](crow::websocket::Connection& conn) {
BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
if (sessions.size() == maxSessions)
diff --git a/include/nbd_proxy.hpp b/include/nbd_proxy.hpp
index 7b90e90..85fb2d4 100644
--- a/include/nbd_proxy.hpp
+++ b/include/nbd_proxy.hpp
@@ -252,17 +252,15 @@
{
BMCWEB_ROUTE(app, "/nbd/<str>")
.websocket()
- .onopen([](crow::websocket::Connection& conn,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .onopen([](crow::websocket::Connection& conn) {
BMCWEB_LOG_DEBUG << "nbd-proxy.onopen(" << &conn << ")";
auto getUserInfoHandler =
- [&conn, asyncResp](
- const boost::system::error_code ec,
- boost::container::flat_map<
- std::string, std::variant<bool, std::string,
- std::vector<std::string>>>
- userInfo) {
+ [&conn](const boost::system::error_code ec,
+ boost::container::flat_map<
+ std::string, std::variant<bool, std::string,
+ std::vector<std::string>>>
+ userInfo) {
if (ec)
{
BMCWEB_LOG_ERROR << "GetUserInfo failed...";
@@ -302,7 +300,7 @@
return;
}
- auto openHandler = [&conn, asyncResp](
+ auto openHandler = [&conn](
const boost::system::error_code ec,
const dbus::utility::
ManagedObjectType& objects) {
diff --git a/include/obmc_console.hpp b/include/obmc_console.hpp
index 478649a..dab9521 100644
--- a/include/obmc_console.hpp
+++ b/include/obmc_console.hpp
@@ -119,8 +119,7 @@
BMCWEB_ROUTE(app, "/console0")
.privileges({{"ConfigureComponents", "ConfigureManager"}})
.websocket()
- .onopen([](crow::websocket::Connection& conn,
- const std::shared_ptr<bmcweb::AsyncResp>&) {
+ .onopen([](crow::websocket::Connection& conn) {
BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
sessions.insert(&conn);
diff --git a/include/vm_websocket.hpp b/include/vm_websocket.hpp
index 34ef82e..08de90e 100644
--- a/include/vm_websocket.hpp
+++ b/include/vm_websocket.hpp
@@ -160,8 +160,7 @@
BMCWEB_ROUTE(app, "/vm/0/0")
.privileges({{"ConfigureComponents", "ConfigureManager"}})
.websocket()
- .onopen([](crow::websocket::Connection& conn,
- const std::shared_ptr<bmcweb::AsyncResp>&) {
+ .onopen([](crow::websocket::Connection& conn) {
BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
if (session != nullptr)