Skip to content

Commit e15f449

Browse files
committed
Update 'async-server', 'async-server-rooms', 'clietn', 'server' to the latest oatpp 1.4.0 API
1 parent 53dca49 commit e15f449

File tree

33 files changed

+129
-123
lines changed

33 files changed

+129
-123
lines changed

async-server-rooms/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
cmake_minimum_required(VERSION 3.1)
1+
cmake_minimum_required(VERSION 3.20)
22

33
set(project_name async-server-rooms) ## rename your project here
44

55
project(${project_name})
66

7-
set(CMAKE_CXX_STANDARD 11)
7+
set(CMAKE_CXX_STANDARD 17)
88

99
include_directories(src)
1010

@@ -21,8 +21,8 @@ add_library(${project_name}-lib
2121

2222
## link libs
2323

24-
find_package(oatpp 1.3.0 REQUIRED)
25-
find_package(oatpp-websocket 1.3.0 REQUIRED)
24+
find_package(oatpp 1.4.0 REQUIRED)
25+
find_package(oatpp-websocket 1.4.0 REQUIRED)
2626

2727
target_link_libraries(${project_name}-lib
2828
PUBLIC oatpp::oatpp
@@ -47,7 +47,7 @@ target_link_libraries(${project_name}-test ${project_name}-lib)
4747
add_dependencies(${project_name}-test ${project_name}-lib)
4848

4949
set_target_properties(${project_name}-lib ${project_name}-exe ${project_name}-test PROPERTIES
50-
CXX_STANDARD 11
50+
CXX_STANDARD 17
5151
CXX_EXTENSIONS OFF
5252
CXX_STANDARD_REQUIRED ON
5353
LINKER_LANGUAGE CXX

async-server-rooms/src/App.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void run() {
2626
oatpp::network::Server server(connectionProvider, connectionHandler);
2727

2828
/* Priny info about server port */
29-
OATPP_LOGI("MyApp", "Server running on port %s", connectionProvider->getProperty("port").getData());
29+
OATPP_LOGi("MyApp", "Server running on port {}", connectionProvider->getProperty("port").toString());
3030

3131
/* Run server */
3232
server.run();
@@ -35,11 +35,11 @@ void run() {
3535

3636
int main(int argc, const char * argv[]) {
3737

38-
oatpp::base::Environment::init();
38+
oatpp::Environment::init();
3939

4040
run();
4141

42-
oatpp::base::Environment::destroy();
42+
oatpp::Environment::destroy();
4343

4444
return 0;
4545
}

async-server-rooms/src/AppComponent.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
#include "oatpp/web/server/HttpRouter.hpp"
88
#include "oatpp/network/tcp/server/ConnectionProvider.hpp"
99

10-
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
10+
#include "oatpp/json/ObjectMapper.hpp"
1111

12-
#include "oatpp/core/macro/component.hpp"
12+
#include "oatpp/macro/component.hpp"
1313

1414
/**
15-
* Class which creates and holds Application components and registers components in oatpp::base::Environment
15+
* Class which creates and holds Application components and registers components in oatpp::Environment
1616
* Order of components initialization is from top to bottom
1717
*/
1818
class AppComponent {
@@ -56,7 +56,7 @@ class AppComponent {
5656
* Create ObjectMapper component to serialize/deserialize DTOs in Contoller's API
5757
*/
5858
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::data::mapping::ObjectMapper>, apiObjectMapper)([] {
59-
return oatpp::parser::json::mapping::ObjectMapper::createShared();
59+
return std::make_shared<oatpp::json::ObjectMapper>();
6060
}());
6161

6262
/**

async-server-rooms/src/controller/RoomsController.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
#include "oatpp/network/ConnectionHandler.hpp"
1010

11-
#include "oatpp/core/macro/codegen.hpp"
12-
#include "oatpp/core/macro/component.hpp"
11+
#include "oatpp/macro/codegen.hpp"
12+
#include "oatpp/macro/component.hpp"
1313

1414

1515
#include OATPP_CODEGEN_BEGIN(ApiController) //<-- codegen begin

async-server-rooms/src/rooms/Peer.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
#include "oatpp-websocket/AsyncWebSocket.hpp"
66

7-
#include "oatpp/core/async/Lock.hpp"
8-
#include "oatpp/core/async/Executor.hpp"
7+
#include "oatpp/async/Lock.hpp"
8+
#include "oatpp/async/Executor.hpp"
99

10-
#include "oatpp/core/macro/component.hpp"
10+
#include "oatpp/macro/component.hpp"
1111

1212
class Room; // FWD
1313

async-server-rooms/test/WSTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
void WSTest::onRun() {
88

9-
OATPP_LOGD(TAG, "TODO - write tests");
9+
OATPP_LOGd(TAG, "TODO - write tests");
1010

1111
}

async-server-rooms/test/tests.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ void runTests() {
1111

1212
int main() {
1313

14-
oatpp::base::Environment::init();
14+
oatpp::Environment::init();
1515

1616
runTests();
1717

1818
/* Print how much objects were created during app running, and what have left-probably leaked */
1919
/* Disable object counting for release builds using '-D OATPP_DISABLE_ENV_OBJECT_COUNTERS' flag for better performance */
2020
std::cout << "\nEnvironment:\n";
21-
std::cout << "objectsCount = " << oatpp::base::Environment::getObjectsCount() << "\n";
22-
std::cout << "objectsCreated = " << oatpp::base::Environment::getObjectsCreated() << "\n\n";
21+
std::cout << "objectsCount = " << oatpp::Environment::getObjectsCount() << "\n";
22+
std::cout << "objectsCreated = " << oatpp::Environment::getObjectsCreated() << "\n\n";
2323

24-
OATPP_ASSERT(oatpp::base::Environment::getObjectsCount() == 0);
24+
OATPP_ASSERT(oatpp::Environment::getObjectsCount() == 0);
2525

26-
oatpp::base::Environment::destroy();
26+
oatpp::Environment::destroy();
2727

2828
return 0;
2929
}

async-server/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
cmake_minimum_required(VERSION 3.1)
1+
cmake_minimum_required(VERSION 3.20)
22

33
set(project_name async-websocket-server) ## rename your project here
44

55
project(${project_name})
66

7-
set(CMAKE_CXX_STANDARD 11)
7+
set(CMAKE_CXX_STANDARD 17)
88

99
include_directories(src)
1010

@@ -17,8 +17,8 @@ add_library(${project_name}-lib
1717

1818
## link libs
1919

20-
find_package(oatpp 1.3.0 REQUIRED)
21-
find_package(oatpp-websocket 1.3.0 REQUIRED)
20+
find_package(oatpp 1.4.0 REQUIRED)
21+
find_package(oatpp-websocket 1.4.0 REQUIRED)
2222

2323
target_link_libraries(${project_name}-lib
2424
PUBLIC oatpp::oatpp
@@ -43,7 +43,7 @@ target_link_libraries(${project_name}-test ${project_name}-lib)
4343
add_dependencies(${project_name}-test ${project_name}-lib)
4444

4545
set_target_properties(${project_name}-lib ${project_name}-exe ${project_name}-test PROPERTIES
46-
CXX_STANDARD 11
46+
CXX_STANDARD 17
4747
CXX_EXTENSIONS OFF
4848
CXX_STANDARD_REQUIRED ON
4949
LINKER_LANGUAGE CXX

async-server/src/App.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void run() {
2626
oatpp::network::Server server(connectionProvider, connectionHandler);
2727

2828
/* Priny info about server port */
29-
OATPP_LOGI("MyApp", "Server running on port %s", connectionProvider->getProperty("port").getData());
29+
OATPP_LOGi("MyApp", "Server running on port {}", connectionProvider->getProperty("port").toString());
3030

3131
/* Run server */
3232
server.run();
@@ -35,11 +35,11 @@ void run() {
3535

3636
int main(int argc, const char * argv[]) {
3737

38-
oatpp::base::Environment::init();
38+
oatpp::Environment::init();
3939

4040
run();
4141

42-
oatpp::base::Environment::destroy();
42+
oatpp::Environment::destroy();
4343

4444
return 0;
4545
}

async-server/src/AppComponent.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
#include "oatpp/web/server/HttpRouter.hpp"
88
#include "oatpp/network/tcp/server/ConnectionProvider.hpp"
99

10-
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
10+
#include "oatpp/json/ObjectMapper.hpp"
1111

12-
#include "oatpp/core/macro/component.hpp"
12+
#include "oatpp/macro/component.hpp"
1313

1414
/**
15-
* Class which creates and holds Application components and registers components in oatpp::base::Environment
15+
* Class which creates and holds Application components and registers components in oatpp::Environment
1616
* Order of components initialization is from top to bottom
1717
*/
1818
class AppComponent {
@@ -56,7 +56,7 @@ class AppComponent {
5656
* Create ObjectMapper component to serialize/deserialize DTOs in Contoller's API
5757
*/
5858
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::data::mapping::ObjectMapper>, apiObjectMapper)([] {
59-
return oatpp::parser::json::mapping::ObjectMapper::createShared();
59+
return std::make_shared<oatpp::json::ObjectMapper>();
6060
}());
6161

6262
/**

0 commit comments

Comments
 (0)