#ifndef TCPSERVERPLUGIN_H
|
#define TCPSERVERPLUGIN_H
|
|
#include "PluginInterface.h"
|
#include "IPC.h"
|
#include <nlohmann/json.hpp>
|
#include <memory>
|
#include <TcpServer.h>
|
#include <glog/logging.h>
|
|
class TcpServerPlugin : public IPlugin {
|
public:
|
TcpServerPlugin(IPC *ipc);
|
~TcpServerPlugin();
|
|
void handleMessage(const Command& cmd) override;
|
void updateConfig(const nlohmann::json& config) override;
|
const std::string getPluginName() override;
|
|
void onClientConnect(sockets::ClientHandle client);
|
void onClientDisconnect(sockets::ClientHandle client, const sockets::SocketRet& ret);
|
void onReceiveClientData(sockets::ClientHandle client, const char* data, size_t size);
|
|
const std::string plugin_name = "TcpServer";
|
|
private:
|
void startServer();
|
void stopServer();
|
|
IPC *ipc;
|
nlohmann::json config;
|
bool running;
|
std::unique_ptr<sockets::TcpServer<TcpServerPlugin>> server;
|
};
|
|
extern "C" IPlugin* create(IPC * ipc);
|
|
#endif // TCPSERVERPLUGIN_H
|