| 382 | } |
| 383 | |
| 384 | std::unique_ptr<Sock> Session::StreamAccept() |
| 385 | { |
| 386 | auto sock = Hello(); |
| 387 | |
| 388 | const Reply& reply = SendRequestAndGetReply( |
| 389 | *sock, strprintf("STREAM ACCEPT ID=%s SILENT=false", m_session_id), false); |
| 390 | |
| 391 | const std::string& result = reply.Get("RESULT"); |
| 392 | |
| 393 | if (result == "OK") { |
| 394 | return sock; |
| 395 | } |
| 396 | |
| 397 | if (result == "INVALID_ID") { |
| 398 | // If our session id is invalid, then force session re-creation on next usage. |
| 399 | Disconnect(); |
| 400 | } |
| 401 | |
| 402 | throw std::runtime_error(strprintf("\"%s\"", reply.full)); |
| 403 | } |
| 404 | |
| 405 | void Session::Disconnect() |
| 406 | { |