10000 Merge branch 'release/v0.7.0' · cinemast/libjson-rpc-cpp@a5bc3de · GitHub
[go: up one dir, main page]

Skip to content

Commit a5bc3de

Browse files
author
Peter Spiess-Knafl
committed
Merge branch 'release/v0.7.0'
2 parents 31b8a66 + bfd0f8d commit a5bc3de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2467
-143
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ before_install:
1111
- sudo make install && sudo ldconfig
1212
- cd .. && sudo rm -rf libmicrohttpd-0.9.44
1313
- sudo pip install cpp-coveralls
14+
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
15+
- sudo apt-get update -qq
16+
- if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.8; fi
17+
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
1418

1519
install:
1620
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
@@ -25,7 +29,6 @@ script:
2529
- mkdir -p build && cd build
2630
- cmake -DCMAKE_BUILD_TYPE=Debug -DHTTP_CLIENT=${HTTP_CLIENT} -DHTTP_SERVER=${HTTP_SERVER} -DCOMPILE_STUBGEN=${COMPILE_STUBGEN} ..
2731
- make
28-
- valgrind --leak-check=full --error-exitcode=1 ./bin/unit_testsuite
2932
- make test
3033
- sudo make install && sudo ldconfig
3134
- g++ ../src/examples/simpleclient.cpp -ljsonrpccpp-client -ljsoncpp -ljsonrpccpp-common -lcurl -o sampleclient

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Marek Kotewicz <marek.kotewicz@gmail.com>
3131
Alexandre Poirot <alexandre.poirot@gmail.com>
3232
+ added client and server connectors that use Unix Domain Sockets
3333
+ adapted build file to generate pkg-config file for this lib.
34+
+ added client and server connectors that u F438 se Tcp Sockets on Linux and Windows (uses native socket and thread API on each OS)
3435

3536
Bugfixes (chronological order)
3637
==============================

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
Changes in v0.7.0
2+
-----------------
3+
- Change: Requiring C++11 support (gcc >= 4.8)
4+
- Fix: armhf compatibility
5+
- Fix: Invalid client id field handling (removed int only check)
6+
- Fix: Security issues in unixdomainsocket connectors
7+
- Fix: Missing CURL include directive
8+
- Fix: Parallel build which failed due to failing CATCH dependency
9+
- Fix: Handling 64-bit ids
10+
- Fix: Invalid parameter check
11+
- Fix: Invalid pointer handling in HTTP-Server
12+
- NEW: HttpServer can now be configured to listen localhost only
13+
- NEW: TCP Server + Client connectors
14+
115
Changes in v0.6.0
216
-----------------
317
- NEW: pkg-config files for all shared libraries

CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if (${CMAKE_MAJOR_VERSION} GREATER 2)
1111
endif()
1212

1313
set(MAJOR_VERSION 0)
14-
set(MINOR_VERSION 6)
14+
set(MINOR_VERSION 7)
1515
set(PATCH_VERSION 0)
1616
set(SO_VERSION 0)
1717

@@ -25,16 +25,24 @@ endif()
2525

2626
# defaults for modules that can be enabled/disabled
2727
if(UNIX)
28-
set(UNIX_DOMAIN_SOCKET_SERVER YES CACHE BOOL "Include Unix Domain Socket server")
29-
set(UNIX_DOMAIN_SOCKET_CLIENT YES CACHE BOOL "Include Unix Domain Socket client")
28+
set(UNIX_DOMAIN_SOCKET_SERVER YES CACHE BOOL "Include Unix Domain Socket server")
29+
set(UNIX_DOMAIN_SOCKET_CLIENT YES CACHE BOOL "Include Unix Domain Socket client")
3030
endif(UNIX)
31+
set(TCP_SOCKET_SERVER NO CACHE BOOL "Include Tcp Socket server")
32+
set(TCP_SOCKET_CLIENT NO CACHE BOOL "Include Tcp Socket client")
3133
set(HTTP_SERVER YES CACHE BOOL "Include HTTP server using libmicrohttpd")
3234
set(HTTP_CLIENT YES CACHE BOOL "Include HTTP client support using curl")
3335
set(COMPILE_TESTS YES CACHE BOOL "Compile test framework")
3436
set(COMPILE_STUBGEN YES CACHE BOOL "Compile the stubgenerator")
3537
set(COMPILE_EXAMPLES YES CACHE BOOL "Compile example programs")
3638

3739
# print actual settings
40+
if(UNIX)
41+
message(STATUS "UNIX_DOMAIN_SOCKET_SERVER: ${UNIX_DOMAIN_SOCKET_SERVER}")
42+
message(STATUS "UNIX_DOMAIN_SOCKET_CLIENT: ${UNIX_DOMAIN_SOCKET_CLIENT}")
43+
endif(UNIX)
44+
message(STATUS "TCP_SOCKET_SERVER: ${TCP_SOCKET_SERVER}")
45+
message(STATUS "TCP_SOCKET_CLIENT: ${TCP_SOCKET_CLIENT}")
3846
message(STATUS "HTTP_SERVER: ${HTTP_SERVER}")
3947
message(STATUS "HTTP_CLIENT: ${HTTP_CLIENT}")
4048
if(UNIX)

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ It is fully JSON-RPC [2.0 & 1.0 compatible](http://www.jsonrpc.org/specification
1111
**5 good reasons for using libjson-rpc-cpp in your next RPC project**
1212
- Full JSON-RPC 2.0 & 1.0 Client and Server Support.
1313
- jsonrpcstub - a tool that generates stub-classes for your JSON-RPC client AND server applications.
14-
- Ready to use HTTP server and client to provide simple interfaces for your JSON-RPC application.
14+
- Ready to use HTTP + TCP server and client to provide simple interfaces for your JSON-RPC application.
1515
- Cross platform build support and [precompiled binaries for WIN32](http://spiessknafl.at/libjson-rpc-cpp).
1616
- Super liberal [MIT-License](http://en.wikipedia.org/wiki/MIT_License).
1717

@@ -111,6 +111,8 @@ Default configuration should be fine for most systems, but here are available co
111111
- `-DHTTP_CLIENT=NO` disable the curl client.
112112
- `-DUNIX_DOMAIN_SOCKET_SERVER=NO` disable the unix domain socket server connector.
113113
- `-DUNIX_DOMAIN_SOCKET_CLIENT=NO` disable the unix domain socket client connector.
114+
- `-DTCP_SOCKET_SERVER=NO` disable the tcp socket server connector.
115+
- `-DTCP_SOCKET_CLIENT=NO` disable the tcp socket client connector.
114116

115117
Using the framework
116118
===================

cmake/CMakeCompilerSettings.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
55
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
6-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Wnon-virtual-dtor -fprofile-arcs -ftest-coverage -fPIC -O0")
6+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wformat -Wno-format-extra-args -Wformat-security -Wformat-nonliteral -Wformat=2 -Wextra -Wnon-virtual-dtor -fprofile-arcs -ftest-coverage -fPIC -O0")
77
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
88
# TODO figure clang stuff to enable test-coverage
99
# Instrument Program flow should be set to Yes

dev/ci.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ build_configuration() {
77
cd build
88
cmake $1 ..
99
make
10-
make test
1110
mkdir -p root
1211
make DESTDIR=root install
1312
cd ..
@@ -37,11 +36,11 @@ valgrind --leak-check=full --xml=yes --xml-file=../reports/valgrind.xml ./bin/un
3736

3837

3938
echo "Generating coverage report"
40-
gcovr -x -r .. > ../reports/coverage.xml
41-
gcovr -r .. --html --html-details -o ../reports/coverage.html
39+
gcovr -e "build" -e "src/test" -x -r .. > ../reports/coverage.xml
40+
gcovr -e "build" -e "src/test" -r .. --html --html-details -o ../reports/coverage.html
4241

4342
echo "Generating cppcheck report"
44-
cppcheck --enable=all --xml ../src --xml-version=2 2> ../reports/cppcheck.xml
43+
cppcheck -I ../src --enable=all --xml ../src --xml-version=2 2> ../reports/cppcheck.xml
4544

4645
cd ..
4746
echo "Cleanup that mess"

src/examples/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@ include_directories(${CMAKE_BINARY_DIR})
3636
include_directories(${JSONCPP_INCLUDE_DIRS})
3737
include_directories(${MHD_INCLUDE_DIRS})
3838

39+
if(UNIX)
40+
if (UNIX_DOMAIN_SOCKET_SERVER AND UNIX_DOMAIN_SOCKET_CLIENT)
41+
add_executable(unixdomainsocketserversample unixdomainsocketserver.cpp)
42+
target_link_libraries(unixdomainsocketserversample jsonrpcserver)
43+
44+
add_executable(unixdomainsocketclientsample unixdomainsocketclient.cpp)
45+
target_link_libraries(unixdomainsocketclientsample jsonrpcclient)
46+
endif (UNIX_DOMAIN_SOCKET_SERVER AND UNIX_DOMAIN_SOCKET_CLIENT)
47+
endif(UNIX)
48+
49+
if (TCP_SOCKET_SERVER AND TCP_SOCKET_CLIENT)
50+
add_executable(tcpsocketclient tcpsocketclient.cpp)
51+
target_link_libraries(tcpsocketclient jsonrpcclient)
52+
53+
add_executable(tcpsocketserver tcpsocketserver.cpp)
54+
target_link_libraries(tcpsocketserver jsonrpcserver)
55+
endif (TCP_SOCKET_SERVER AND TCP_SOCKET_CLIENT)
56+
3957
if(HTTP_SERVER)
4058
add_executable(simpleserversample simpleserver.cpp)
4159
target_link_libraries(simpleserversample jsonrpcserver)
@@ -59,3 +77,4 @@ if (COMPILE_STUBGEN)
5977
target_link_libraries(stubserversample jsonrpcserver)
6078
endif()
6179
endif()
80+

src/examples/stubclient.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ using namespace std;
1717

1818
int main()
1919
{
20+
21+
Json::Value a = 3;
22+
Json::Value b = "3";
23+
2 F438 4+
std::map<Json::Value, Json::Value> responses;
25+
26+
responses[a] = b;
27+
responses[b] = "asölfj";
28+
29+
cout << responses[b] << endl;
30+
31+
if (a == b)
32+
{
33+
cout << a.toStyledString() << " == " << b.toStyledString() << endl;
34+
}
35+
else
36+
{
37+
cout << a.toStyledString() << " != " << b.toStyledString() << endl;
38+
}
39+
2040
HttpClient httpclient("http://localhost:8383");
2141
//StubClient c(httpclient, JSONRPC_CLIENT_V1); //json-rpc 1.0
2242
StubClient c(httpclient, JSONRPC_CLIENT_V2); //json-rpc 2.0

src/examples/tcpsocketclient.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* @file tcpsocketclient.cpp
3+
* @date 17.07.2015
4+
* @author Alexandre Poirot <alexandre.poirot@legrand.fr>
5+
* @brief tcpsocketclient.cpp
6+
*/
7+
8+
#include <jsonrpccpp/client.h>
9+
#include <jsonrpccpp/client/connectors/tcpsocketclient.h>
10+
#include <iostream>
11+
#include <cstdlib>
12+
13+
using namespace jsonrpc;
14+
using namespace std;
15+
16+
int main(int argc, char** argv)
17+
{
18+
string host;
19+
unsigned int port;
20+
21+
if(argc == 3) {
22+
host = string(argv[1]);
23+
port = atoi(argv[2]);
24+
}
25+
else {
26+
host = "127.0.0.1";
27+
port = 6543;
28+
}
29+
30+
31+
cout << "Params are :" << endl;
32+
cout << "\t host: " << host << endl;
33+
cout << "\t port: " << port << endl;
34+
35+
TcpSocketClient client(host, port);
36+
Client c(client);
37+
38+
Json::Value params;
39+
params["name"] = "Peter";
40+
41+
try
42+
{
43+
cout << c.CallMethod("sayHello", params) << endl;
44+
}
45+
catch (JsonRpcException& e)
46+
{
47+
cerr << e.what() << endl;
48+
}
49+
50+
51+
}

0 commit comments

Comments
 (0)
0