consolidate connection

This commit is contained in:
Eric Mertens 2025-02-05 09:47:52 -08:00
parent 2b4bb1f071
commit 847a149e12
2 changed files with 7 additions and 15 deletions

View File

@ -151,7 +151,12 @@ auto Connection::dispatch_line(char *line, bool flush) -> void
} }
} }
auto Connection::write_line(std::string message) -> void auto Connection::close() -> void
{
stream_.close();
}
auto Connection::write_irc(std::string message) -> void
{ {
BOOST_LOG_TRIVIAL(debug) << "SEND: " << message; BOOST_LOG_TRIVIAL(debug) << "SEND: " << message;
message += "\r\n"; message += "\r\n";
@ -169,16 +174,6 @@ auto Connection::write_line(std::string message) -> void
} }
} }
auto Connection::close() -> void
{
stream_.close();
}
auto Connection::write_irc(std::string message) -> void
{
write_line(std::move(message));
}
auto Connection::write_irc(std::string front, std::string_view last) -> void auto Connection::write_irc(std::string front, std::string_view last) -> void
{ {
bool colon = last.starts_with(":"); bool colon = last.starts_with(":");
@ -191,7 +186,7 @@ auto Connection::write_irc(std::string front, std::string_view last) -> void
} }
front += colon ? " :" : " "; front += colon ? " :" : " ";
front += last; front += last;
write_line(std::move(front)); write_irc(std::move(front));
} }
static static

View File

@ -82,9 +82,6 @@ public:
auto start(Settings) -> void; auto start(Settings) -> void;
auto close() -> void; auto close() -> void;
/// Write bytes into the socket.
auto write_line(std::string message) -> void;
/// Build and send well-formed IRC message from individual parameters /// Build and send well-formed IRC message from individual parameters
auto write_irc(std::string) -> void; auto write_irc(std::string) -> void;
auto write_irc(std::string, std::string_view) -> void; auto write_irc(std::string, std::string_view) -> void;