1/*************************************************************************
2 * libjson-rpc-cpp
3 *************************************************************************
4 * @file unixdomainsocketclient.h
5 * @date 17.10.2016
6 * @author Alexandre Poirot <alexandre.poirot@legrand.fr>
7 * @license See attached LICENSE.txt
8 ************************************************************************/
9
10#ifndef JSONRPC_CPP_TCPSOCKETCLIENT_H_
11#define JSONRPC_CPP_TCPSOCKETCLIENT_H_
12
13#include <jsonrpccpp/client/iclientconnector.h>
14#include <jsonrpccpp/common/exception.h>
15#include <string>
16
17namespace jsonrpc {
18 /**
19 * This class provides an embedded TCP Socket Client that sends Requests over a tcp socket and read result from same socket.
20 * It uses the delimiter character to distinct a full RPC Message over the tcp flow. This character is parametered on
21 * compilation time in implementation files. The default value for this delimiter is 0x0A a.k.a. "new line".
22 * This class hides OS specific features in real implementation of this client. Currently it has implementation for
23 * both Linux and Windows.
24 */
25 class TcpSocketClient : public IClientConnector {
26 public:
27 /**
28 * @brief TcpSocketClient, constructor for the included TcpSocketClient
29 *
30 * Instanciates the real implementation of TcpSocketClientPrivate depending on running OS.
31 *
32 * @param ipToConnect The ipv4 address on which the client should try to connect
33 * @param port The port on which the client should try to connect
34 */
35 TcpSocketClient(const std::string &ipToConnect, const unsigned int &port);
36 /**
37 * @brief ~TcpSocketClient, the destructor of TcpSocketClient
38 */
39 virtual ~TcpSocketClient();
40 /**
41 * @brief The IClientConnector::SendRPCMessage method overload.
42 * @param message The message to send
43 * @param result The result of the call returned by the servsr
44 * @throw JsonRpcException Thrown when an issue is encounter with socket manipulation (see message of exception for more information about what happened).
45 */
46 virtual void SendRPCMessage(const std::string &message, std::string &result);
47
48 protected:
49 IClientConnector *realSocket; /*!< A pointer to the real implementation of this class depending of running OS*/
50 };
51
52} /* namespace jsonrpc */
53#endif /* JSONRPC_CPP_TCPSOCKETCLIENT_H_ */
54