diff --git a/server/stream_session.cpp b/server/stream_session.cpp index b9307a3c..35c2cfc7 100644 --- a/server/stream_session.cpp +++ b/server/stream_session.cpp @@ -43,6 +43,19 @@ StreamSession::~StreamSession() } +std::string StreamSession::getIP() +{ + try + { + return socket_.remote_endpoint().address().to_string(); + } + catch (...) + { + return "0.0.0.0"; + } +} + + void StreamSession::read_next() { boost::asio::async_read(socket_, boost::asio::buffer(buffer_, base_msg_size_), diff --git a/server/stream_session.hpp b/server/stream_session.hpp index c31508fb..8d3f42d8 100644 --- a/server/stream_session.hpp +++ b/server/stream_session.hpp @@ -128,10 +128,7 @@ public: std::string clientId; - std::string getIP() - { - return socket_.remote_endpoint().address().to_string(); - } + std::string getIP(); void setPcmStream(streamreader::PcmStreamPtr pcmStream); const streamreader::PcmStreamPtr pcmStream() const;