Fix server crash if client crashes during connect

This commit is contained in:
badaix 2020-05-02 14:25:55 +02:00
parent 3ed76e2059
commit b23255389f
2 changed files with 14 additions and 4 deletions

View file

@ -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_),

View file

@ -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;