1 /* 2 * Copyright (c) 2022 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 #ifndef REMOTE_EXECUTOR_STUB_H 17 #define REMOTE_EXECUTOR_STUB_H 18 19 #include <optional> 20 21 #include "attributes.h" 22 #include "co_auth_client_defines.h" 23 #include "executor_callback_interface.h" 24 #include "nocopyable.h" 25 #include "remote_connect_manager.h" 26 #include "schedule_node.h" 27 28 namespace OHOS { 29 namespace UserIam { 30 namespace UserAuth { 31 class RemoteExecutorStub : public std::enable_shared_from_this<RemoteExecutorStub> { 32 public: 33 public: 34 RemoteExecutorStub(); 35 virtual ~RemoteExecutorStub(); 36 37 // ConnectionListener 38 void OnMessage(const std::string &connectionName, const std::string &srcEndPoint, 39 const std::shared_ptr<Attributes> &request, std::shared_ptr<Attributes> &reply); 40 41 // ScheduleNode 42 int32_t OnMessage(ExecutorRole dstRole, const std::vector<uint8_t> &msg); 43 int32_t ContinueSchedule(ResultCode resultCode, const std::shared_ptr<Attributes> &finalResult); 44 45 // ExecutorCallbackInterface 46 int32_t ProcBeginExecuteRequest(Attributes &attr); 47 48 private: 49 int32_t ProcSendDataMsg(Attributes &attr); 50 51 std::recursive_mutex mutex_; 52 std::shared_ptr<ConnectionListener> connectionCallback_ = nullptr; 53 std::shared_ptr<ScheduleNode> remoteScheduleNode_ = nullptr; 54 uint64_t executorIndex_ = 0; 55 std::string connectionName_ = ""; 56 std::string endPointName_ = ""; 57 std::optional<uint64_t> contextId_ = std::nullopt; 58 }; 59 } // namespace UserAuth 60 } // namespace UserIam 61 } // namespace OHOS 62 #endif // REMOTE_EXECUTOR_STUB_H