Skip to content

Commit

Permalink
Merge pull request #7 from fawdlstty/master
Browse files Browse the repository at this point in the history
Reserve these parameters for the HTTP request before upgrading to WebSocket protocol
  • Loading branch information
xmh0511 authored Apr 23, 2021
2 parents 7143fe1 + 52f6e28 commit 1c53b7e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion asio
Submodule asio updated 1272 files
1 change: 1 addition & 0 deletions xfinal/connection.hpp
Original file line number Diff line number Diff line change
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->decode_url_params_ = req_.move_key_params ();
ws->move_socket(std::move(handler->socket_));
}
});
Expand Down
3 changes: 3 additions & 0 deletions xfinal/http_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,9 @@ namespace xfinal {
std::map<std::string, nonstd::any>&& move_user_data() {
return std::move(user_data_);
}
std::map<std::string, std::string>&& move_key_params () {
return std::move (decode_url_params_);
}
private:
nonstd::string_view method_;
nonstd::string_view url_;
Expand Down
2 changes: 1 addition & 1 deletion xfinal/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <tuple>
#include "string_view.hpp"
#include <vector>
#include <filesystem.hpp>
#include "ghc/filesystem.hpp"
#include <sstream>
#include "json.hpp"
#include <ctime>
Expand Down
4 changes: 4 additions & 0 deletions xfinal/websokcet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ namespace xfinal {
asio::ip::tcp::socket& socket() {
return *socket_;
}
std::map<std::string, std::string> key_params () const noexcept {
return decode_url_params_;
}
private:
void move_socket(std::unique_ptr<asio::ip::tcp::socket>&& socket) {
socket_ = std::move(socket);
Expand Down Expand Up @@ -565,6 +568,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

0 comments on commit 1c53b7e

Please sign in to comment.