Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/Simple-WebSocket-Server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Maroszek <maroszek@gmx.net>2020-07-28 17:38:18 +0300
committerMichael Maroszek <maroszek@gmx.net>2020-07-28 17:38:18 +0300
commit95cefd438f06dab3ef2c501c0d1f1105121ce305 (patch)
treee8e05f5d51b3bf6e099ee6a6603359499d193351
parentaf45eb04b86718eac820ba8a3e781d8044ce3de1 (diff)
move endpoint initialization further up
-rw-r--r--server_ws.hpp22
1 files changed, 8 insertions, 14 deletions
diff --git a/server_ws.hpp b/server_ws.hpp
index 955975c..6af4384 100644
--- a/server_ws.hpp
+++ b/server_ws.hpp
@@ -79,13 +79,7 @@ namespace SimpleWeb {
friend class SocketServer<socket_type>;
public:
- Connection(std::unique_ptr<socket_type> &&socket_) noexcept : socket(std::move(socket_)), timeout_idle(0), closed(false) {
- try {
- endpoint = socket->lowest_layer().remote_endpoint();
- }
- catch (...) {
- }
- }
+ Connection(std::unique_ptr<socket_type> &&socket_) noexcept : socket(std::move(socket_)), timeout_idle(0), closed(false) {}
std::string method, path, query_string, http_version;
@@ -121,13 +115,7 @@ namespace SimpleWeb {
/// Used to call Server::upgrade.
template <typename... Args>
Connection(std::shared_ptr<ScopeRunner> handler_runner_, long timeout_idle, Args &&... args) noexcept
- : handler_runner(std::move(handler_runner_)), socket(new socket_type(std::forward<Args>(args)...)), timeout_idle(timeout_idle), closed(false) {
- try {
- endpoint = socket->lowest_layer().remote_endpoint();
- }
- catch (...) {
- }
- }
+ : handler_runner(std::move(handler_runner_)), socket(new socket_type(std::forward<Args>(args)...)), timeout_idle(timeout_idle), closed(false) {}
std::shared_ptr<ScopeRunner> handler_runner;
@@ -542,6 +530,12 @@ namespace SimpleWeb {
}
void write_handshake(const std::shared_ptr<Connection> &connection) {
+ try {
+ connection->endpoint = connection->socket->lowest_layer().remote_endpoint();
+ }
+ catch (...) {
+ }
+
for(auto &regex_endpoint : endpoint) {
regex::smatch path_match;
if(regex::regex_match(connection->path, path_match, regex_endpoint.first)) {