aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/server/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--server/main/session.cpp9
-rw-r--r--server/main/session.hpp2
2 files changed, 5 insertions, 6 deletions
diff --git a/server/main/session.cpp b/server/main/session.cpp
index 0ee7f75..7249f0e 100644
--- a/server/main/session.cpp
+++ b/server/main/session.cpp
@@ -87,15 +87,14 @@ std::string Session::consume_input(std::size_t bytes) {
return input;
}
-void Session::write(std::string output) {
+void Session::write(const std::string& output) {
const auto self = shared_from_this();
+ std::ostream os(&m_buffer);
// Include CR (so that Windows' telnet client works)
- output += "\r\n";
+ os << output << "\r\n";
- boost::asio::const_buffer buffer{output.c_str(), output.length()};
-
- boost::asio::async_write(m_socket, std::move(buffer), boost::asio::bind_executor(m_strand,
+ boost::asio::async_write(m_socket, m_buffer, boost::asio::bind_executor(m_strand,
[this, self] (const boost::system::error_code& ec, std::size_t bytes) {
handle_write(ec, bytes);
}));
diff --git a/server/main/session.hpp b/server/main/session.hpp
index ace3755..98f28dd 100644
--- a/server/main/session.hpp
+++ b/server/main/session.hpp
@@ -25,7 +25,7 @@ private:
void close();
void read();
- void write(std::string);
+ void write(const std::string&);
void handle_read(const boost::system::error_code&, std::size_t);
void handle_write(const boost::system::error_code&, std::size_t);