Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reserve these parameters for the HTTP request before upgrading to WebSocket protocol #7

Merged
merged 4 commits into from Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions xfinal/connection.hpp
Expand Up @@ -660,6 +660,7 @@ namespace xfinal {
cancel_keep_timer();
auto ws = handler->router_.websokcets().start_webscoket(view2str(handler->req_.get_event_index_str()));
ws->user_data_ = req_.move_user_data();
ws->key_params().swap(req_.key_params());
fawdlstty marked this conversation as resolved.
Show resolved Hide resolved
ws->move_socket(std::move(handler->socket_));
}
});
Expand Down
2 changes: 1 addition & 1 deletion xfinal/http_handler.hpp
Expand Up @@ -143,7 +143,7 @@ namespace xfinal {
return {};
}

std::map<std::string, std::string> key_params() const noexcept { //获取问号键值对的map
std::map<std::string, std::string> &key_params() noexcept { //获取问号键值对的map
fawdlstty marked this conversation as resolved.
Show resolved Hide resolved
return decode_url_params_;
}

Expand Down
2 changes: 1 addition & 1 deletion xfinal/utils.hpp
Expand Up @@ -3,7 +3,7 @@
#include <tuple>
#include "string_view.hpp"
#include <vector>
#include <filesystem.hpp>
#include "ghc/filesystem.hpp"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

头文件的问题,如果单独测试xfinal通过,应该作为单独的pr提交

#include <sstream>
#include "json.hpp"
#include <ctime>
Expand Down
4 changes: 4 additions & 0 deletions xfinal/websokcet.hpp
Expand Up @@ -113,6 +113,9 @@ namespace xfinal {
asio::ip::tcp::socket& socket() {
return *socket_;
}
std::map<std::string, std::string> &key_params () noexcept {
fawdlstty marked this conversation as resolved.
Show resolved Hide resolved
return decode_url_params_;
}
private:
void move_socket(std::unique_ptr<asio::ip::tcp::socket>&& socket) {
socket_ = std::move(socket);
Expand Down Expand Up @@ -554,6 +557,7 @@ namespace xfinal {
std::atomic_bool socket_is_open_{ false };
std::atomic_bool is_writing_{ false };
std::map<std::string, nonstd::any> user_data_;
std::map<std::string, std::string> decode_url_params_;
};

class websocket_hub {
Expand Down