Skip to content

Commit

Permalink
Merge branch 'release/v0.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Spiess-Knafl committed Aug 10, 2016
2 parents 31b8a66 + bfd0f8d commit a5bc3de
Show file tree
Hide file tree
Showing 42 changed files with 2,467 additions and 143 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ before_install:
- sudo make install && sudo ldconfig
- cd .. && sudo rm -rf libmicrohttpd-0.9.44
- sudo pip install cpp-coveralls
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
- sudo apt-get update -qq
- if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.8; fi
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi

install:
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
Expand All @@ -25,7 +29,6 @@ script:
- mkdir -p build && cd build
- cmake -DCMAKE_BUILD_TYPE=Debug -DHTTP_CLIENT=${HTTP_CLIENT} -DHTTP_SERVER=${HTTP_SERVER} -DCOMPILE_STUBGEN=${COMPILE_STUBGEN} ..
- make
- valgrind --leak-check=full --error-exitcode=1 ./bin/unit_testsuite
- make test
- sudo make install && sudo ldconfig
- g++ ../src/examples/simpleclient.cpp -ljsonrpccpp-client -ljsoncpp -ljsonrpccpp-common -lcurl -o sampleclient
Expand Down
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Marek Kotewicz <[email protected]>
Alexandre Poirot <[email protected]>
+ added client and server connectors that use Unix Domain Sockets
+ adapted build file to generate pkg-config file for this lib.
+ added client and server connectors that use Tcp Sockets on Linux and Windows (uses native socket and thread API on each OS)

Bugfixes (chronological order)
==============================
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
Changes in v0.7.0
-----------------
- Change: Requiring C++11 support (gcc >= 4.8)
- Fix: armhf compatibility
- Fix: Invalid client id field handling (removed int only check)
- Fix: Security issues in unixdomainsocket connectors
- Fix: Missing CURL include directive
- Fix: Parallel build which failed due to failing CATCH dependency
- Fix: Handling 64-bit ids
- Fix: Invalid parameter check
- Fix: Invalid pointer handling in HTTP-Server
- NEW: HttpServer can now be configured to listen localhost only
- NEW: TCP Server + Client connectors

Changes in v0.6.0
-----------------
- NEW: pkg-config files for all shared libraries
Expand Down
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (${CMAKE_MAJOR_VERSION} GREATER 2)
endif()

set(MAJOR_VERSION 0)
set(MINOR_VERSION 6)
set(MINOR_VERSION 7)
set(PATCH_VERSION 0)
set(SO_VERSION 0)

Expand All @@ -25,16 +25,24 @@ endif()

# defaults for modules that can be enabled/disabled
if(UNIX)
set(UNIX_DOMAIN_SOCKET_SERVER YES CACHE BOOL "Include Unix Domain Socket server")
set(UNIX_DOMAIN_SOCKET_CLIENT YES CACHE BOOL "Include Unix Domain Socket client")
set(UNIX_DOMAIN_SOCKET_SERVER YES CACHE BOOL "Include Unix Domain Socket server")
set(UNIX_DOMAIN_SOCKET_CLIENT YES CACHE BOOL "Include Unix Domain Socket client")
endif(UNIX)
set(TCP_SOCKET_SERVER NO CACHE BOOL "Include Tcp Socket server")
set(TCP_SOCKET_CLIENT NO CACHE BOOL "Include Tcp Socket client")
set(HTTP_SERVER YES CACHE BOOL "Include HTTP server using libmicrohttpd")
set(HTTP_CLIENT YES CACHE BOOL "Include HTTP client support using curl")
set(COMPILE_TESTS YES CACHE BOOL "Compile test framework")
set(COMPILE_STUBGEN YES CACHE BOOL "Compile the stubgenerator")
set(COMPILE_EXAMPLES YES CACHE BOOL "Compile example programs")

# print actual settings
if(UNIX)
message(STATUS "UNIX_DOMAIN_SOCKET_SERVER: ${UNIX_DOMAIN_SOCKET_SERVER}")
message(STATUS "UNIX_DOMAIN_SOCKET_CLIENT: ${UNIX_DOMAIN_SOCKET_CLIENT}")
endif(UNIX)
message(STATUS "TCP_SOCKET_SERVER: ${TCP_SOCKET_SERVER}")
message(STATUS "TCP_SOCKET_CLIENT: ${TCP_SOCKET_CLIENT}")
message(STATUS "HTTP_SERVER: ${HTTP_SERVER}")
message(STATUS "HTTP_CLIENT: ${HTTP_CLIENT}")
if(UNIX)
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It is fully JSON-RPC [2.0 & 1.0 compatible](http://www.jsonrpc.org/specification
**5 good reasons for using libjson-rpc-cpp in your next RPC project**
- Full JSON-RPC 2.0 & 1.0 Client and Server Support.
- jsonrpcstub - a tool that generates stub-classes for your JSON-RPC client AND server applications.
- Ready to use HTTP server and client to provide simple interfaces for your JSON-RPC application.
- Ready to use HTTP + TCP server and client to provide simple interfaces for your JSON-RPC application.
- Cross platform build support and [precompiled binaries for WIN32](http://spiessknafl.at/libjson-rpc-cpp).
- Super liberal [MIT-License](http://en.wikipedia.org/wiki/MIT_License).

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

Using the framework
===================
Expand Down
2 changes: 1 addition & 1 deletion cmake/CMakeCompilerSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Wnon-virtual-dtor -fprofile-arcs -ftest-coverage -fPIC -O0")
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")
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# TODO figure clang stuff to enable test-coverage
# Instrument Program flow should be set to Yes
Expand Down
7 changes: 3 additions & 4 deletions dev/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ build_configuration() {
cd build
cmake $1 ..
make
make test
mkdir -p root
make DESTDIR=root install
cd ..
Expand Down Expand Up @@ -37,11 +36,11 @@ valgrind --leak-check=full --xml=yes --xml-file=../reports/valgrind.xml ./bin/un


echo "Generating coverage report"
gcovr -x -r .. > ../reports/coverage.xml
gcovr -r .. --html --html-details -o ../reports/coverage.html
gcovr -e "build" -e "src/test" -x -r .. > ../reports/coverage.xml
gcovr -e "build" -e "src/test" -r .. --html --html-details -o ../reports/coverage.html

echo "Generating cppcheck report"
cppcheck --enable=all --xml ../src --xml-version=2 2> ../reports/cppcheck.xml
cppcheck -I ../src --enable=all --xml ../src --xml-version=2 2> ../reports/cppcheck.xml

cd ..
echo "Cleanup that mess"
Expand Down
19 changes: 19 additions & 0 deletions src/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ include_directories(${CMAKE_BINARY_DIR})
include_directories(${JSONCPP_INCLUDE_DIRS})
include_directories(${MHD_INCLUDE_DIRS})

if(UNIX)
if (UNIX_DOMAIN_SOCKET_SERVER AND UNIX_DOMAIN_SOCKET_CLIENT)
add_executable(unixdomainsocketserversample unixdomainsocketserver.cpp)
target_link_libraries(unixdomainsocketserversample jsonrpcserver)

add_executable(unixdomainsocketclientsample unixdomainsocketclient.cpp)
target_link_libraries(unixdomainsocketclientsample jsonrpcclient)
endif (UNIX_DOMAIN_SOCKET_SERVER AND UNIX_DOMAIN_SOCKET_CLIENT)
endif(UNIX)

if (TCP_SOCKET_SERVER AND TCP_SOCKET_CLIENT)
add_executable(tcpsocketclient tcpsocketclient.cpp)
target_link_libraries(tcpsocketclient jsonrpcclient)

add_executable(tcpsocketserver tcpsocketserver.cpp)
target_link_libraries(tcpsocketserver jsonrpcserver)
endif (TCP_SOCKET_SERVER AND TCP_SOCKET_CLIENT)

if(HTTP_SERVER)
add_executable(simpleserversample simpleserver.cpp)
target_link_libraries(simpleserversample jsonrpcserver)
Expand All @@ -59,3 +77,4 @@ if (COMPILE_STUBGEN)
target_link_libraries(stubserversample jsonrpcserver)
endif()
endif()

20 changes: 20 additions & 0 deletions src/examples/stubclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@ using namespace std;

int main()
{

Json::Value a = 3;
Json::Value b = "3";

std::map<Json::Value, Json::Value> responses;

responses[a] = b;
responses[b] = "asölfj";

cout << responses[b] << endl;

if (a == b)
{
cout << a.toStyledString() << " == " << b.toStyledString() << endl;
}
else
{
cout << a.toStyledString() << " != " << b.toStyledString() << endl;
}

HttpClient httpclient("http://localhost:8383");
//StubClient c(httpclient, JSONRPC_CLIENT_V1); //json-rpc 1.0
StubClient c(httpclient, JSONRPC_CLIENT_V2); //json-rpc 2.0
Expand Down
51 changes: 51 additions & 0 deletions src/examples/tcpsocketclient.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* @file tcpsocketclient.cpp
* @date 17.07.2015
* @author Alexandre Poirot <[email protected]>
* @brief tcpsocketclient.cpp
*/

#include <jsonrpccpp/client.h>
#include <jsonrpccpp/client/connectors/tcpsocketclient.h>
#include <iostream>
#include <cstdlib>

using namespace jsonrpc;
using namespace std;

int main(int argc, char** argv)
{
string host;
unsigned int port;

if(argc == 3) {
host = string(argv[1]);
port = atoi(argv[2]);
}
else {
host = "127.0.0.1";
port = 6543;
}


cout << "Params are :" << endl;
cout << "\t host: " << host << endl;
cout << "\t port: " << port << endl;

TcpSocketClient client(host, port);
Client c(client);

Json::Value params;
params["name"] = "Peter";

try
{
cout << c.CallMethod("sayHello", params) << endl;
}
catch (JsonRpcException& e)
{
cerr << e.what() << endl;
}


}
82 changes: 82 additions & 0 deletions src/examples/tcpsocketserver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* @file unixdomainsocketserver.cpp
* @date 11.05.2015
* @author Alexandre Poirot
* @brief unixdomainsocketserver.cpp
*/

#include <stdio.h>
#include <string>
#include <iostream>
#include <jsonrpccpp/server.h>
#include <jsonrpccpp/server/connectors/tcpsocketserver.h>
#include <cstdlib>


using namespace jsonrpc;
using namespace std;

class SampleServer : public AbstractServer<SampleServer>
{
public:
SampleServer(TcpSocketServer &server) :
AbstractServer<SampleServer>(server)
{
this->bindAndAddMethod(Procedure("sayHello", PARAMS_BY_NAME, JSON_STRING, "name", JSON_STRING, NULL), &SampleServer::sayHello);
this->bindAndAddNotification(Procedure("notifyServer", PARAMS_BY_NAME, NULL), &SampleServer::notifyServer);
}

//method
void sayHello(const Json::Value& request, Json::Value& response)
{
response = "Hello: " + request["name"].asString();
}

//notification
void notifyServer(const Json::Value& request)
{
(void)request;
cout << "server received some Notification" << endl;
}
};

int main(int argc, char** argv)
{
try
{
string ip;
unsigned int port;

if(argc == 3)
{
ip = string(argv[1]);
port = atoi(argv[2]);
}
else
{
ip = "127.0.0.1";
port = 6543;
}

cout << "Params are :" << endl;
cout << "\t ip: " << ip << endl;
cout << "\t port: " << port << endl;

TcpSocketServer server(ip, port);
SampleServer serv(server);
if (serv.StartListening())
{
cout << "Server started successfully" << endl;
getchar();
serv.StopListening();
}
else
{
cout << "Error starting Server" << endl;
}
}
catch (jsonrpc::JsonRpcException& e)
{
cerr << e.what() << endl;
}
}
33 changes: 33 additions & 0 deletions src/examples/unixdomainsocketclient.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @file unixdomainsocketclient.cpp
* @date 11.05.2015
* @author Alexandre Poirot <[email protected]>
* @brief unixdomainsocketclient.cpp
*/

#include <jsonrpccpp/client.h>
#include <jsonrpccpp/client/connectors/unixdomainsocketclient.h>
#include <iostream>

using namespace jsonrpc;
using namespace std;

int main()
{
UnixDomainSocketClient client("/tmp/unixdomainsocketexample");
Client c(client);

Json::Value params;
params["name"] = "Peter";

try
{
cout << c.CallMethod("sayHello", params) << endl;
}
catch (JsonRpcException& e)
{
cerr << e.what() << endl;
}


}
Loading

0 comments on commit a5bc3de

Please sign in to comment.