62 lines
1.4 KiB
C++
62 lines
1.4 KiB
C++
#ifndef INCLUDE_SERVER_PROTOCOLFACADE_H_
|
|
#define INCLUDE_SERVER_PROTOCOLFACADE_H_
|
|
|
|
#include <iostream>
|
|
#include <memory>
|
|
#include <di/Buffer.h>
|
|
#include <di/rpc/Reader.h>
|
|
#include <di/rpc/Msg.h>
|
|
#include <server/LowLevel.h>
|
|
#include <di/rpc/lowlevel.h>
|
|
|
|
struct Message;
|
|
|
|
class ProtocolFacade {
|
|
public:
|
|
/**
|
|
* encode messages
|
|
* @param msg message that need to be encoded
|
|
* @param obuf pointer to buffer
|
|
* @return succes or failure
|
|
*/
|
|
bool encode(const struct Message &msg, std::shared_ptr<Di::Buffer> obuf);
|
|
|
|
/**
|
|
* decode messages
|
|
* @param buf pointer to buffer
|
|
* @param msg pointer to message that need to be decoded
|
|
* @return succes or failure
|
|
*/
|
|
bool decode(std::shared_ptr<Di::Buffer> buf, std::shared_ptr<struct Message> *msg);
|
|
private:
|
|
LowLevel __lowlevel; /** low level handle */
|
|
Di::Rpc::Reader __reader; /** RPC reader handle */
|
|
|
|
/**
|
|
* Creates a reply message containing the current DI-Net time
|
|
*/
|
|
bool __createTimeReply(std::shared_ptr<Di::Buffer> obuf);
|
|
|
|
/**
|
|
* send encrypted message
|
|
* @param conn connection where message need to be send
|
|
*/
|
|
bool __messageEncrypted(void *conn);
|
|
|
|
/**
|
|
* send non-encrypted message
|
|
* @param conn connection where message need to be send
|
|
*/
|
|
bool __messagePlain(void *conn);
|
|
|
|
/**
|
|
* send repky message
|
|
* @param conn connection where reply need to be send
|
|
* @param success
|
|
*/
|
|
bool __sendReply(void *conn, bool success);
|
|
};
|
|
|
|
|
|
#endif // INCLUDE_SERVER_PROTOCOLFACADE_H_
|