1234567891011121314151617181920212223242526272829303132333435363738 |
- /*
- * tcp_client.h
- *
- * Created on: 2022年10月5日
- * Author: Allen
- */
- #ifndef JNI_NET_TCP_CLIENT_H_
- #define JNI_NET_TCP_CLIENT_H_
- #include <atomic>
- #include <functional>
- #include <thread>
- #include "net.h"
- #include "service/BusinessConfig.h"
- #include "tcp_model.h"
- class TcpClient {
- public:
- virtual ~TcpClient();
- static TcpClient* instance();
- void startTcp();
- void closeTcp();
- void sendMsg(const char* msg);
- void sendMsgWithCb(const char* msg, TcpCallback callback);
- static bool connected();
- static bool isConnect();
- static bool busy();
- private:
- TcpClient();
- void internalSendMsg(const char* msg);
- private:
- std::atomic<bool> busy_;
- };
- #endif /* JNI_NET_TCP_CLIENT_H_ */
|