| 459 | } |
| 460 | |
| 461 | std::unique_ptr<Sock> Session::StreamAccept() |
| 462 | { |
| 463 | auto sock = Hello(); |
| 464 | |
| 465 | const Reply& reply = SendRequestAndGetReply( |
| 466 | *sock, strprintf("STREAM ACCEPT ID=%s SILENT=false", m_session_id), false); |
| 467 | |
| 468 | const std::string& result = reply.Get("RESULT"); |
| 469 | |
| 470 | if (result == "OK") { |
| 471 | return sock; |
| 472 | } |
| 473 | |
| 474 | if (result == "INVALID_ID") { |
| 475 | // If our session id is invalid, then force session re-creation on next usage. |
| 476 | Disconnect(); |
| 477 | } |
| 478 | |
| 479 | throw std::runtime_error(strprintf("\"%s\"", reply.full)); |
| 480 | } |
| 481 | |
| 482 | void Session::Disconnect() |
| 483 | { |