• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 PANDA_TOOLING_INSPECTOR_TEST_TEST_SERVER_H
17 #define PANDA_TOOLING_INSPECTOR_TEST_TEST_SERVER_H
18 
19 #include "../server_endpoint.h"
20 #include "test_config.h"
21 #include "test_event_loop.h"
22 
23 #include "websocketpp/connection.hpp"
24 
25 #include <functional>
26 #include <string_view>
27 #include <utility>
28 
29 namespace panda::tooling::inspector::test {
30 class TestLogger;
31 
32 class TestServer : public ServerEndpoint<TestConfig>, public TestEventLoop {
33 public:
34     TestServer(std::string_view name, TestLogger &logger);
35 
36     void Connect(const websocketpp::connection<TestConfig>::ptr &clientConnection, TestEventLoop &clientEventLoop);
37 
OnConnect(std::function<void ()> && handler)38     void OnConnect(std::function<void()> &&handler)
39     {
40         endpoint_.set_open_handler(std::bind(std::move(handler)));
41     }
42 };
43 }  // namespace panda::tooling::inspector::test
44 
45 #endif  // PANDA_TOOLING_INSPECTOR_TEST_TEST_SERVER_H
46