| 428 | } |
| 429 | |
| 430 | std::string Server::ListSessions() { |
| 431 | LOG(TRACE) << "Entering Server::ListSessions"; |
| 432 | |
| 433 | // Manually construct the serialized command for getting |
| 434 | // session capabilities. |
| 435 | std::string get_caps_command = "{ \"name\" : \"" + |
| 436 | webdriver::CommandType::GetSessionCapabilities |
| 437 | + "\"" + |
| 438 | ", \"locator\" : {}, \"parameters\" : {} }"; |
| 439 | |
| 440 | Json::Value sessions(Json::arrayValue); |
| 441 | SessionMap::iterator it = this->sessions_.begin(); |
| 442 | for (; it != this->sessions_.end(); ++it) { |
| 443 | // Each element of the GetSessionList command is an object with two |
| 444 | // named properties, "id" and "capabilities". We already know the |
| 445 | // ID, so we execute the GetSessionCapabilities command on each session |
| 446 | // to be able to return the capabilities. |
| 447 | Json::Value session_descriptor; |
| 448 | session_descriptor["id"] = it->first; |
| 449 | |
| 450 | SessionHandle session = it->second; |
| 451 | std::string serialized_session_response; |
| 452 | session->ExecuteCommand(get_caps_command, &serialized_session_response); |
| 453 | |
| 454 | Response session_response; |
| 455 | session_response.Deserialize(serialized_session_response); |
| 456 | session_descriptor["capabilities"] = session_response.value(); |
| 457 | sessions.append(session_descriptor); |
| 458 | } |
| 459 | Response response; |
| 460 | response.SetSuccessResponse(sessions); |
| 461 | return response.Serialize(); |
| 462 | } |
| 463 | |
| 464 | bool Server::LookupSession(const std::string& session_id, |
| 465 | SessionHandle* session_handle) { |
no test coverage detected