\brief Get a new, empty session option map & its id key; {"",NULLPTR} on collision.
| 177 | |
| 178 | /// \brief Get a new, empty session option map & its id key; {"",NULLPTR} on collision. |
| 179 | std::pair<std::string, std::shared_ptr<FlightSession>> |
| 180 | ServerSessionMiddlewareFactory::CreateNewSession() { |
| 181 | auto new_id = id_generator_(); |
| 182 | auto session = std::make_shared<FlightSession>(); |
| 183 | |
| 184 | const std::lock_guard<std::shared_mutex> l(session_store_lock_); |
| 185 | if (session_store_.count(new_id)) { |
| 186 | // Collision |
| 187 | return {"", NULLPTR}; |
| 188 | } |
| 189 | session_store_[new_id] = session; |
| 190 | |
| 191 | return {new_id, session}; |
| 192 | } |
| 193 | |
| 194 | Status ServerSessionMiddlewareFactory::CloseSession(std::string id) { |
| 195 | const std::lock_guard<std::shared_mutex> l(session_store_lock_); |