Renamed classes to match style guide.
using namespace icinga;
/**
- * Constructor for the TCPClient class.
+ * Constructor for the TcpClient class.
*
* @param role The role of the TCP client socket.
*/
-TCPClient::TCPClient(TCPClientRole role)
+TcpClient::TcpClient(TcpClientRole role)
{
m_Role = role;
*
* @returns The role.
*/
-TCPClientRole TCPClient::GetRole(void) const
+TcpClientRole TcpClient::GetRole(void) const
{
return m_Role;
}
/**
* Registers the socket and starts processing events for it.
*/
-void TCPClient::Start(void)
+void TcpClient::Start(void)
{
- TCPSocket::Start();
+ TcpSocket::Start();
- OnReadable += bind_weak(&TCPClient::ReadableEventHandler, shared_from_this());
- OnWritable += bind_weak(&TCPClient::WritableEventHandler, shared_from_this());
+ OnReadable += bind_weak(&TcpClient::ReadableEventHandler, shared_from_this());
+ OnWritable += bind_weak(&TcpClient::WritableEventHandler, shared_from_this());
}
/**
* @param node The node.
* @param service The service.
*/
-void TCPClient::Connect(const string& node, const string& service)
+void TcpClient::Connect(const string& node, const string& service)
{
m_Role = RoleOutbound;
*
* @returns The send queue.
*/
-FIFO::Ptr TCPClient::GetSendQueue(void)
+FIFO::Ptr TcpClient::GetSendQueue(void)
{
return m_SendQueue;
}
*
* @returns The recv queue.
*/
-FIFO::Ptr TCPClient::GetRecvQueue(void)
+FIFO::Ptr TcpClient::GetRecvQueue(void)
{
return m_RecvQueue;
}
* @param - Event arguments.
* @returns 0
*/
-int TCPClient::ReadableEventHandler(const EventArgs&)
+int TcpClient::ReadableEventHandler(const EventArgs&)
{
int rc;
* @param - Event arguments.
* @returns 0
*/
-int TCPClient::WritableEventHandler(const EventArgs&)
+int TcpClient::WritableEventHandler(const EventArgs&)
{
int rc;
*
* @returns true
*/
-bool TCPClient::WantsToRead(void) const
+bool TcpClient::WantsToRead(void) const
{
return true;
}
*
* @returns true if data should be written, false otherwise.
*/
-bool TCPClient::WantsToWrite(void) const
+bool TcpClient::WantsToWrite(void) const
{
return (m_SendQueue->GetSize() > 0);
}
* @param role The role of the new client.
* @returns The new client.
*/
-TCPClient::Ptr icinga::TCPClientFactory(TCPClientRole role)
+TcpClient::Ptr icinga::TcpClientFactory(TcpClientRole role)
{
- return make_shared<TCPClient>(role);
+ return make_shared<TcpClient>(role);
}
*
* @ingroup base
*/
-enum TCPClientRole
+enum TcpClientRole
{
RoleInbound, /**< Inbound socket, i.e. one that was returned
from accept(). */
*
* @ingroup base
*/
-class I2_BASE_API TCPClient : public TCPSocket
+class I2_BASE_API TcpClient : public TcpSocket
{
private:
- TCPClientRole m_Role;
+ TcpClientRole m_Role;
FIFO::Ptr m_SendQueue;
FIFO::Ptr m_RecvQueue;
virtual int WritableEventHandler(const EventArgs& ea);
public:
- typedef shared_ptr<TCPClient> Ptr;
- typedef weak_ptr<TCPClient> WeakPtr;
+ typedef shared_ptr<TcpClient> Ptr;
+ typedef weak_ptr<TcpClient> WeakPtr;
- TCPClient(TCPClientRole role);
+ TcpClient(TcpClientRole role);
- TCPClientRole GetRole(void) const;
+ TcpClientRole GetRole(void) const;
virtual void Start(void);
};
/**
- * Returns a new unconnected TCPClient object that has the specified
+ * Returns a new unconnected TcpClient object that has the specified
* connection role.
*
* @param role The role of the new object.
- * @returns A new TCPClient object.
+ * @returns A new TcpClient object.
*/
-TCPClient::Ptr TCPClientFactory(TCPClientRole role);
+TcpClient::Ptr TcpClientFactory(TcpClientRole role);
}
using namespace icinga;
/**
- * Constructor for the TCPServer class.
+ * Constructor for the TcpServer class.
*/
-TCPServer::TCPServer(void)
+TcpServer::TcpServer(void)
{
- m_ClientFactory = bind(&TCPClientFactory, RoleInbound);
+ m_ClientFactory = bind(&TcpClientFactory, RoleInbound);
}
/**
*
* @param clientFactory The client factory function.
*/
-void TCPServer::SetClientFactory(function<TCPClient::Ptr()> clientFactory)
+void TcpServer::SetClientFactory(function<TcpClient::Ptr()> clientFactory)
{
m_ClientFactory = clientFactory;
}
*
* @returns The client factory function.
*/
-function<TCPClient::Ptr()> TCPServer::GetFactoryFunction(void) const
+function<TcpClient::Ptr()> TcpServer::GetFactoryFunction(void) const
{
return m_ClientFactory;
}
/**
* Registers the TCP server and starts processing events for it.
*/
-void TCPServer::Start(void)
+void TcpServer::Start(void)
{
- TCPSocket::Start();
+ TcpSocket::Start();
- OnReadable += bind_weak(&TCPServer::ReadableEventHandler, shared_from_this());
+ OnReadable += bind_weak(&TcpServer::ReadableEventHandler, shared_from_this());
}
/**
* Starts listening for incoming client connections.
*/
-void TCPServer::Listen(void)
+void TcpServer::Listen(void)
{
int rc = listen(GetFD(), SOMAXCONN);
* @param - Event arguments.
* @returns 0
*/
-int TCPServer::ReadableEventHandler(const EventArgs&)
+int TcpServer::ReadableEventHandler(const EventArgs&)
{
int fd;
sockaddr_storage addr;
NewClientEventArgs nea;
nea.Source = shared_from_this();
- nea.Client = static_pointer_cast<TCPSocket>(m_ClientFactory());
+ nea.Client = static_pointer_cast<TcpSocket>(m_ClientFactory());
nea.Client->SetFD(fd);
nea.Client->Start();
OnNewClient(nea);
*
* @returns true
*/
-bool TCPServer::WantsToRead(void) const
+bool TcpServer::WantsToRead(void) const
{
return true;
}
*/
struct I2_BASE_API NewClientEventArgs : public EventArgs
{
- TCPSocket::Ptr Client; /**< The new client object. */
+ TcpSocket::Ptr Client; /**< The new client object. */
};
/**
*
* @ingroup base
*/
-class I2_BASE_API TCPServer : public TCPSocket
+class I2_BASE_API TcpServer : public TcpSocket
{
private:
int ReadableEventHandler(const EventArgs& ea);
- function<TCPClient::Ptr()> m_ClientFactory;
+ function<TcpClient::Ptr()> m_ClientFactory;
public:
- typedef shared_ptr<TCPServer> Ptr;
- typedef weak_ptr<TCPServer> WeakPtr;
+ typedef shared_ptr<TcpServer> Ptr;
+ typedef weak_ptr<TcpServer> WeakPtr;
- TCPServer(void);
+ TcpServer(void);
- void SetClientFactory(function<TCPClient::Ptr()> function);
- function<TCPClient::Ptr()> GetFactoryFunction(void) const;
+ void SetClientFactory(function<TcpClient::Ptr()> function);
+ function<TcpClient::Ptr()> GetFactoryFunction(void) const;
virtual void Start();
*
* @param family The socket family for the new socket.
*/
-void TCPSocket::MakeSocket(int family)
+void TcpSocket::MakeSocket(int family)
{
assert(GetFD() == INVALID_SOCKET);
* @param service The service.
* @param family The address family for the socket.
*/
-void TCPSocket::Bind(string service, int family)
+void TcpSocket::Bind(string service, int family)
{
Bind(string(), service, family);
}
* @param service The service.
* @param family The address family for the socket.
*/
-void TCPSocket::Bind(string node, string service, int family)
+void TcpSocket::Bind(string node, string service, int family)
{
addrinfo hints;
addrinfo *result;
*
* @ingroup base
*/
-class I2_BASE_API TCPSocket : public Socket
+class I2_BASE_API TcpSocket : public Socket
{
private:
void MakeSocket(int family);
public:
- typedef shared_ptr<TCPSocket> Ptr;
- typedef weak_ptr<TCPSocket> WeakPtr;
+ typedef shared_ptr<TcpSocket> Ptr;
+ typedef weak_ptr<TcpSocket> WeakPtr;
void Bind(string service, int family);
void Bind(string node, string service, int family);
using namespace icinga;
-int I2_EXPORT TLSClient::m_SSLIndex;
-bool I2_EXPORT TLSClient::m_SSLIndexInitialized = false;
+int I2_EXPORT TlsClient::m_SSLIndex;
+bool I2_EXPORT TlsClient::m_SSLIndexInitialized = false;
/**
- * Constructor for the TLSClient class.
+ * Constructor for the TlsClient class.
*
* @param role The role of the client.
* @param sslContext The SSL context for the client.
*/
-TLSClient::TLSClient(TCPClientRole role, shared_ptr<SSL_CTX> sslContext) : TCPClient(role)
+TlsClient::TlsClient(TcpClientRole role, shared_ptr<SSL_CTX> sslContext) : TcpClient(role)
{
m_SSLContext = sslContext;
m_BlockRead = false;
*
* @param certificate An X509 certificate.
*/
-void TLSClient::NullCertificateDeleter(X509 *certificate)
+void TlsClient::NullCertificateDeleter(X509 *certificate)
{
/* Nothing to do here. */
}
*
* @returns The X509 certificate.
*/
-shared_ptr<X509> TLSClient::GetClientCertificate(void) const
+shared_ptr<X509> TlsClient::GetClientCertificate(void) const
{
- return shared_ptr<X509>(SSL_get_certificate(m_SSL.get()), &TLSClient::NullCertificateDeleter);
+ return shared_ptr<X509>(SSL_get_certificate(m_SSL.get()), &TlsClient::NullCertificateDeleter);
}
/**
*
* @returns The X509 certificate.
*/
-shared_ptr<X509> TLSClient::GetPeerCertificate(void) const
+shared_ptr<X509> TlsClient::GetPeerCertificate(void) const
{
return shared_ptr<X509>(SSL_get_peer_certificate(m_SSL.get()), X509_free);
}
/**
* Registers the TLS socket and starts processing events for it.
*/
-void TLSClient::Start(void)
+void TlsClient::Start(void)
{
- TCPClient::Start();
+ TcpClient::Start();
m_SSL = shared_ptr<SSL>(SSL_new(m_SSLContext.get()), SSL_free);
throw InvalidArgumentException("No X509 client certificate was specified.");
if (!m_SSLIndexInitialized) {
- m_SSLIndex = SSL_get_ex_new_index(0, (void *)"TLSClient", NULL, NULL, NULL);
+ m_SSLIndex = SSL_get_ex_new_index(0, (void *)"TlsClient", NULL, NULL, NULL);
m_SSLIndexInitialized = true;
}
SSL_set_ex_data(m_SSL.get(), m_SSLIndex, this);
SSL_set_verify(m_SSL.get(), SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
- &TLSClient::SSLVerifyCertificate);
+ &TlsClient::SSLVerifyCertificate);
BIO *bio = BIO_new_socket(GetFD(), 0);
SSL_set_bio(m_SSL.get(), bio, bio);
* @param - Event arguments.
* @returns 0
*/
-int TLSClient::ReadableEventHandler(const EventArgs&)
+int TlsClient::ReadableEventHandler(const EventArgs&)
{
int rc;
* @param - Event arguments.
* @returns 0
*/
-int TLSClient::WritableEventHandler(const EventArgs&)
+int TlsClient::WritableEventHandler(const EventArgs&)
{
int rc;
*
* @returns true if data should be read, false otherwise.
*/
-bool TLSClient::WantsToRead(void) const
+bool TlsClient::WantsToRead(void) const
{
if (SSL_want_read(m_SSL.get()))
return true;
if (m_BlockRead)
return false;
- return TCPClient::WantsToRead();
+ return TcpClient::WantsToRead();
}
/**
*
* @returns true if data should be written, false otherwise.
*/
-bool TLSClient::WantsToWrite(void) const
+bool TlsClient::WantsToWrite(void) const
{
if (SSL_want_write(m_SSL.get()))
return true;
if (m_BlockWrite)
return false;
- return TCPClient::WantsToWrite();
+ return TcpClient::WantsToWrite();
}
/**
*
* @param from_dtor Whether this method was invoked from the destructor.
*/
-void TLSClient::CloseInternal(bool from_dtor)
+void TlsClient::CloseInternal(bool from_dtor)
{
SSL_shutdown(m_SSL.get());
- TCPClient::CloseInternal(from_dtor);
+ TcpClient::CloseInternal(from_dtor);
}
/**
* Handles an OpenSSL error.
*/
-void TLSClient::HandleSSLError(void)
+void TlsClient::HandleSSLError(void)
{
int code = ERR_get_error();
}
/**
- * Factory function for the TLSClient class.
+ * Factory function for the TlsClient class.
*
* @param role The role of the TLS socket.
* @param sslContext The SSL context for the socket.
* @returns A new TLS socket.
*/
-TCPClient::Ptr icinga::TLSClientFactory(TCPClientRole role, shared_ptr<SSL_CTX> sslContext)
+TcpClient::Ptr icinga::TlsClientFactory(TcpClientRole role, shared_ptr<SSL_CTX> sslContext)
{
- return make_shared<TLSClient>(role, sslContext);
+ return make_shared<TlsClient>(role, sslContext);
}
/**
* @param x509Context X509 context for the certificate.
* @returns 1 if the verification was successful, 0 otherwise.
*/
-int TLSClient::SSLVerifyCertificate(int ok, X509_STORE_CTX *x509Context)
+int TlsClient::SSLVerifyCertificate(int ok, X509_STORE_CTX *x509Context)
{
SSL *ssl = (SSL *)X509_STORE_CTX_get_ex_data(x509Context, SSL_get_ex_data_X509_STORE_CTX_idx());
- TLSClient *client = (TLSClient *)SSL_get_ex_data(ssl, m_SSLIndex);
+ TlsClient *client = (TlsClient *)SSL_get_ex_data(ssl, m_SSLIndex);
if (client == NULL)
return 0;
vcea.Source = client->shared_from_this();
vcea.ValidCertificate = (ok != 0);
vcea.Context = x509Context;
- vcea.Certificate = shared_ptr<X509>(x509Context->cert, &TLSClient::NullCertificateDeleter);
+ vcea.Certificate = shared_ptr<X509>(x509Context->cert, &TlsClient::NullCertificateDeleter);
client->OnVerifyCertificate(vcea);
return (int)vcea.ValidCertificate;
*
* @ingroup base
*/
-class I2_BASE_API TLSClient : public TCPClient
+class I2_BASE_API TlsClient : public TcpClient
{
private:
shared_ptr<SSL_CTX> m_SSLContext;
void HandleSSLError(void);
public:
- TLSClient(TCPClientRole role, shared_ptr<SSL_CTX> sslContext);
+ TlsClient(TcpClientRole role, shared_ptr<SSL_CTX> sslContext);
shared_ptr<X509> GetClientCertificate(void) const;
shared_ptr<X509> GetPeerCertificate(void) const;
Observable<VerifyCertificateEventArgs> OnVerifyCertificate;
};
-TCPClient::Ptr TLSClientFactory(TCPClientRole role, shared_ptr<SSL_CTX> sslContext);
+TcpClient::Ptr TlsClientFactory(TcpClientRole role, shared_ptr<SSL_CTX> sslContext);
}
*/
struct I2_ICINGA_API NewRequestEventArgs : public EventArgs
{
- typedef shared_ptr<NewRequestEventArgs> Ptr;
- typedef weak_ptr<NewRequestEventArgs> WeakPtr;
-
Endpoint::Ptr Sender;
RpcRequest Request;
};
using namespace icinga;
-JsonRpcClient::JsonRpcClient(TCPClientRole role, shared_ptr<SSL_CTX> sslContext)
- : TLSClient(role, sslContext) { }
+/**
+ * Constructor for the JsonRpcClient class.
+ *
+ * @param role The role of the underlying TCP client.
+ * @param sslContext SSL context for the TLS connection.
+ */
+JsonRpcClient::JsonRpcClient(TcpClientRole role, shared_ptr<SSL_CTX> sslContext)
+ : TlsClient(role, sslContext) { }
void JsonRpcClient::Start(void)
{
- TLSClient::Start();
+ TlsClient::Start();
OnDataAvailable += bind_weak(&JsonRpcClient::DataAvailableHandler, shared_from_this());
}
+/**
+ * Sends a message to the connected peer.
+ *
+ * @param message The message.
+ */
void JsonRpcClient::SendMessage(const MessagePart& message)
{
Netstring::WriteStringToFIFO(GetSendQueue(), message.ToJsonString());
}
+/**
+ * Processes inbound data.
+ *
+ * @param - Event arguments for the event.
+ * @returns 0
+ */
int JsonRpcClient::DataAvailableHandler(const EventArgs&)
{
for (;;) {
Application::Log("Exception while processing message from JSON-RPC client: " + string(ex.GetMessage()));
Close();
- return 1;
+ return 0;
}
}
return 0;
}
-TCPClient::Ptr icinga::JsonRpcClientFactory(TCPClientRole role, shared_ptr<SSL_CTX> sslContext)
+/**
+ * Factory function for JSON-RPC clients.
+ *
+ * @param role The role of the underlying TCP client.
+ * @param sslContext SSL context for the TLS connection.
+ * @returns A new JSON-RPC client.
+ */
+JsonRpcClient::Ptr icinga::JsonRpcClientFactory(TcpClientRole role, shared_ptr<SSL_CTX> sslContext)
{
return make_shared<JsonRpcClient>(role, sslContext);
}
*/
struct I2_JSONRPC_API NewMessageEventArgs : public EventArgs
{
- typedef shared_ptr<NewMessageEventArgs> Ptr;
- typedef weak_ptr<NewMessageEventArgs> WeakPtr;
-
icinga::MessagePart Message;
};
*
* @ingroup jsonrpc
*/
-class I2_JSONRPC_API JsonRpcClient : public TLSClient
+class I2_JSONRPC_API JsonRpcClient : public TlsClient
{
private:
- int DataAvailableHandler(const EventArgs& ea);
+ int DataAvailableHandler(const EventArgs&);
public:
typedef shared_ptr<JsonRpcClient> Ptr;
typedef weak_ptr<JsonRpcClient> WeakPtr;
- JsonRpcClient(TCPClientRole role, shared_ptr<SSL_CTX> sslContext);
+ JsonRpcClient(TcpClientRole role, shared_ptr<SSL_CTX> sslContext);
void SendMessage(const MessagePart& message);
Observable<NewMessageEventArgs> OnNewMessage;
};
-TCPClient::Ptr JsonRpcClientFactory(TCPClientRole role, shared_ptr<SSL_CTX> sslContext);
+JsonRpcClient::Ptr JsonRpcClientFactory(TcpClientRole role, shared_ptr<SSL_CTX> sslContext);
}
using namespace icinga;
+/**
+ * Constructor for the JsonRpcServer class.
+ *
+ * @param sslContext SSL context that should be used for client connections.
+ */
JsonRpcServer::JsonRpcServer(shared_ptr<SSL_CTX> sslContext)
{
SetClientFactory(bind(&JsonRpcClientFactory, RoleInbound, sslContext));
*
* @ingroup jsonrpc
*/
-class I2_JSONRPC_API JsonRpcServer : public TCPServer
+class I2_JSONRPC_API JsonRpcServer : public TcpServer
{
public:
typedef shared_ptr<JsonRpcServer> Ptr;
using namespace icinga;
+/**
+ * Constructor for the MessagePart class.
+ */
MessagePart::MessagePart(void)
{
m_Dictionary = make_shared<Dictionary>();
}
+/**
+ * Constructor for the MessagePart class.
+ *
+ * @param jsonString The JSON string that should be used to initialize
+ * the message.
+ */
MessagePart::MessagePart(string jsonString)
{
json_t *json = cJSON_Parse(jsonString.c_str());
cJSON_Delete(json);
}
+/**
+ * Constructor for the MessagePart class.
+ *
+ * @param dictionary The dictionary that this MessagePart object should wrap.
+ */
MessagePart::MessagePart(const Dictionary::Ptr& dictionary)
{
m_Dictionary = dictionary;
}
+/**
+ * Copy-constructor for the MessagePart class.
+ *
+ * @param message The message that should be copied.
+ */
MessagePart::MessagePart(const MessagePart& message)
{
m_Dictionary = message.GetDictionary();
}
+/**
+ * Converts a JSON object to a dictionary.
+ *
+ * @param json The JSON object.
+ * @returns A dictionary that is equivalent to the JSON object.
+ */
Dictionary::Ptr MessagePart::GetDictionaryFromJson(json_t *json)
{
Dictionary::Ptr dictionary = make_shared<Dictionary>();
return dictionary;
}
+/**
+ * Converts a dictionary to a JSON object.
+ *
+ * @param dictionary The dictionary.
+ * @returns A JSON object that is equivalent to the dictionary. Values that
+ * cannot be represented in JSON are omitted.
+ */
json_t *MessagePart::GetJsonFromDictionary(const Dictionary::Ptr& dictionary)
{
cJSON *json;
return json;
}
+/**
+ * Converts a message into a JSON string.
+ *
+ * @returns A JSON string representing the message.
+ */
string MessagePart::ToJsonString(void) const
{
json_t *json = GetJsonFromDictionary(m_Dictionary);
return result;
}
+/**
+ * Retrieves the underlying dictionary for this message.
+ *
+ * @returns A dictionary.
+ */
Dictionary::Ptr MessagePart::GetDictionary(void) const
{
return m_Dictionary;
}
+/**
+ * Retrieves a property's value.
+ *
+ * @param key The name of the property.
+ * @param[out] The value.
+ * @returns true if the value was retrieved, false otherwise.
+ */
bool MessagePart::GetProperty(string key, MessagePart *value) const
{
Object::Ptr object;
return true;
}
+/**
+ * Sets a property's value.
+ *
+ * @param key The name of the property.
+ * @param value The value.
+ */
void MessagePart::SetProperty(string key, const MessagePart& value)
{
GetDictionary()->SetProperty(key, value.GetDictionary());
}
+/**
+ * Adds an item to the message using an automatically generated property name.
+ *
+ * @param value The value.
+ */
void MessagePart::AddUnnamedProperty(const MessagePart& value)
{
GetDictionary()->AddUnnamedProperty(value.GetDictionary());
}
+/**
+ * Returns an iterator that points to the first element of the dictionary
+ * which holds the properties for the message.
+ *
+ * @returns An iterator.
+ */
DictionaryIterator MessagePart::Begin(void)
{
return GetDictionary()->Begin();
}
+/**
+ * Returns an iterator that points past the last element of the dictionary
+ * which holds the properties for the message.
+ *
+ * @returns An iterator.
+ */
DictionaryIterator MessagePart::End(void)
{
return GetDictionary()->End();
}
-
-MessagePart::operator Dictionary::Ptr(void)
-{
- return GetDictionary();
-}
Dictionary::Ptr GetDictionary(void) const;
+ /**
+ * Retrieves a property's value.
+ *
+ * @param key The name of the property.
+ * @param[out] The value.
+ * @returns true if the value was retrieved, false otherwise.
+ */
template<typename T>
bool GetProperty(string key, T *value) const
{
return GetDictionary()->GetProperty(key, value);
}
+ /**
+ * Sets a property's value.
+ *
+ * @param key The name of the property.
+ * @param value The value.
+ */
template<typename T>
void SetProperty(string key, const T& value)
{
bool GetProperty(string key, MessagePart *value) const;
void SetProperty(string key, const MessagePart& value);
+ /**
+ * Adds an item to the message using an automatically generated property name.
+ *
+ * @param value The value.
+ */
template<typename T>
void AddUnnamedProperty(const T& value)
{
DictionaryIterator Begin(void);
DictionaryIterator End(void);
-
- operator Dictionary::Ptr(void);
};
}
*/
class I2_JSONRPC_API RpcRequest : public MessagePart
{
-
public:
+ /**
+ * Constructor for the RpcRequest class.
+ */
RpcRequest(void) : MessagePart() {
SetVersion("2.0");
}
+ /**
+ * Copy-constructor for the RpcRequest class.
+ *
+ * @param message The message that is to be copied.
+ */
RpcRequest(const MessagePart& message) : MessagePart(message) { }
+ /**
+ * Retrieves the version of the JSON-RPC protocol.
+ *
+ * @param[out] value The value.
+ * @returns true if the value was retrieved, false otherwise.
+ */
inline bool GetVersion(string *value) const
{
return GetProperty("jsonrpc", value);
}
+ /**
+ * Sets the version of the JSON-RPC protocol that should be used.
+ *
+ * @param value The version.
+ */
inline void SetVersion(const string& value)
{
SetProperty("jsonrpc", value);
}
+ /**
+ * Retrieves the method of the JSON-RPC call.
+ *
+ * @param[out] value The method.
+ * @returns true if the value was retrieved, false otherwise.
+ */
inline bool GetMethod(string *value) const
{
return GetProperty("method", value);
}
+ /**
+ * Sets the method for the JSON-RPC call.
+ *
+ * @param value The method.
+ */
inline void SetMethod(const string& value)
{
SetProperty("method", value);
}
+ /**
+ * Retrieves the parameters of the JSON-RPC call.
+ *
+ * @param[out] value The parameters.
+ * @returns true if the value was retrieved, false otherwise.
+ */
inline bool GetParams(MessagePart *value) const
{
return GetProperty("params", value);
}
+ /**
+ * Sets the parameters for the JSON-RPC call.
+ *
+ * @param value The parameters.
+ */
inline void SetParams(const MessagePart& value)
{
SetProperty("params", value);
}
+ /**
+ * Retrieves the ID of the JSON-RPC call.
+ *
+ * @param[out] value The ID.
+ * @return true if the value was retrieved, false otherwise.
+ */
inline bool GetID(string *value) const
{
return GetProperty("id", value);
}
+ /**
+ * Sets the ID for the JSON-RPC call.
+ *
+ * @param value The ID.
+ */
inline void SetID(const string& value)
{
SetProperty("id", value);
class I2_JSONRPC_API RpcResponse : public MessagePart
{
public:
+ /**
+ * Constructor for the RpcResponse class.
+ */
RpcResponse(void) : MessagePart() {
SetVersion("2.0");
}
+ /**
+ * Copy-constructor for the RpcResponse class.
+ *
+ * @param message The message that should be copied.
+ */
RpcResponse(const MessagePart& message) : MessagePart(message) { }
+ /**
+ * Retrieves the version of the JSON-RPC protocol.
+ *
+ * @param[out] value The value.
+ * @returns true if the value was retrieved, false otherwise.
+ */
inline bool GetVersion(string *value) const
{
return GetProperty("jsonrpc", value);
}
+ /**
+ * Sets the version of the JSON-RPC protocol that should be used.
+ *
+ * @param value The version.
+ */
inline void SetVersion(const string& value)
{
SetProperty("jsonrpc", value);
}
- bool GetResult(string *value) const
+ /**
+ * Retrieves the result of the JSON-RPC call.
+ *
+ * @param[out] value The result.
+ * @returns true if the value was retrieved, false otherwise.
+ */
+ bool GetResult(MessagePart *value) const
{
return GetProperty("result", value);
}
- void SetResult(const string& value)
+ /**
+ * Sets the result for the JSON-RPC call.
+ *
+ * @param value The result.
+ */
+ void SetResult(const MessagePart& value)
{
SetProperty("result", value);
}
+ /**
+ * Retrieves the error message of the JSON-RPC call.
+ *
+ * @param[out] value The error message.
+ * @returns true if the value was retrieved, false otherwise.
+ */
bool GetError(string *value) const
{
return GetProperty("error", value);
}
+ /**
+ * Sets the error message for the JSON-RPC call.
+ *
+ * @param value The error message.
+ */
void SetError(const string& value)
{
SetProperty("error", value);
}
+ /**
+ * Retrieves the ID of the JSON-RPC call.
+ *
+ * @param[out] value The ID.
+ * @return true if the value was retrieved, false otherwise.
+ */
bool GetID(string *value) const
{
return GetProperty("id", value);
}
+ /**
+ * Sets the ID for the JSON-RPC call.
+ *
+ * @param value The ID.
+ */
void SetID(const string& value)
{
SetProperty("id", value);