1 // 2 // Copyright (C) 2020 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 #include "host/frontend/webrtc_operator/device_list_handler.h" 17 18 namespace cuttlefish { 19 DeviceListHandler(struct lws * wsi,DeviceRegistry & registry)20DeviceListHandler::DeviceListHandler(struct lws* wsi, 21 DeviceRegistry& registry) 22 : DynHandler(wsi), registry_(registry) {} 23 DoGet()24HttpStatusCode DeviceListHandler::DoGet() { 25 Json::Value reply(Json::ValueType::arrayValue); 26 27 for (const auto& id : registry_.ListDeviceIds()) { 28 reply.append(id); 29 } 30 Json::StreamWriterBuilder json_factory; 31 auto replyAsString = Json::writeString(json_factory, reply); 32 AppendDataOut(replyAsString); 33 return HttpStatusCode::Ok; 34 } DoPost()35HttpStatusCode DeviceListHandler::DoPost() { 36 return HttpStatusCode::NotFound; 37 } 38 39 } // namespace cuttlefish 40