123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- #ifndef __TCPPLUGIN_HPP_
- #define __TCPPLUGIN_HPP_
- #include <iostream>
- #include "UtilBase.hpp"
- #include "TCPClient.hpp"
- #include "requests.hpp"
- #include "config.hpp"
- #include "md5.h"
- #include "uuid.hpp"
- #include "ExpelDevice.h"
- #include "ExpelPlugin.hpp"
- #include "uuid.hpp"
- #include "PluginSubscriber.hpp"
- using namespace std;
- using namespace utility;
- namespace gsd
- {
- class TcpPlugin: public PluginSubscriber<TcpPlugin>, public PluginBase
- {
- private:
- TcpPlugin(): PluginBase(){
- }
- public:
- using Ptr = std::shared_ptr<TcpPlugin>;
-
-
-
- static std::shared_ptr<TcpPlugin> getPtr();
-
-
- static std::shared_ptr<TcpPlugin> CreateNew();
- ~TcpPlugin(){}
-
-
- virtual bool Init();
-
-
- virtual bool StartTask();
-
-
- virtual void Destroy();
-
-
- virtual bool Alive();
-
-
- void SendHeartbeatData();
-
-
- void TCPLoginNetty();
-
-
- bool getLoginNetty();
-
-
- void ListenNettyData(const Buffer::Ptr &buf);
-
-
- void sendRequest(std::string RequestId,std::string CommandEnum, std::string& data,function<void(int, std::string)> t);
-
-
- virtual bool RestPlugin(){
- return true;
- }
- private:
-
-
- TCPClient::Ptr tcpClient = nullptr;
- Timer::Ptr HeartbeatTimer = nullptr;
- Timer::Ptr NettyLoginTimer = nullptr;
-
- bool TcpNettyLogin = false;
-
- std::shared_ptr<ThreadPool> pool = nullptr;
- };
-
- }
- #endif
|