1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#include "agent/target_impl.h" 17 18#include "base/pt_events.h" 19#include "protocol_channel.h" 20 21namespace panda::ecmascript::tooling { 22void TargetImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) 23{ 24 Method method = GetMethodEnum(request.GetMethod()); 25 LOG_DEBUGGER(INFO) << "dispatch [" << request.GetMethod() << "] to TargetImpl"; 26 switch (method) { 27 case Method::SET_AUTO_ATTACH: 28 SetAutoAttach(request); 29 break; 30 default: 31 SendResponse(request, DispatchResponse::Fail("Unknown method: " + request.GetMethod())); 32 break; 33 } 34} 35 36TargetImpl::DispatcherImpl::Method TargetImpl::DispatcherImpl::GetMethodEnum(const std::string& method) 37{ 38 if (method == "setAutoAttach") { 39 return Method::SET_AUTO_ATTACH; 40 } else { 41 return Method::UNKNOWN; 42 } 43} 44 45void TargetImpl::DispatcherImpl::SetAutoAttach(const DispatchRequest &request) 46{ 47 DispatchResponse response = DispatchResponse::Ok(); 48 SendResponse(request, response); 49} 50} // namespace panda::ecmascript::tooling