You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
988 B
C++
56 lines
988 B
C++
#pragma once
|
|
#include <QDebug>
|
|
#include <QDateTime>
|
|
#include <iostream>
|
|
#include <QThread>
|
|
#include <qtcpsocket.h>
|
|
#include "common.h"
|
|
#include "SyncQueue.h"
|
|
|
|
class _TCPSendInfo
|
|
{
|
|
public:
|
|
std::string pics_name;
|
|
|
|
_TCPSendInfo()
|
|
{
|
|
pics_name = "";
|
|
}
|
|
};
|
|
|
|
class threadSendTCP : public QThread {
|
|
public:
|
|
QString ip;
|
|
int port;
|
|
int num = 0;
|
|
|
|
threadSendTCP(QObject* o = nullptr) :QThread(o)
|
|
{
|
|
isLoop = true;
|
|
}
|
|
|
|
~threadSendTCP()
|
|
{
|
|
stop();
|
|
_TCPSendInfo TCPSendInfo;
|
|
Local_TCP_Info_queue->put(TCPSendInfo);
|
|
quit();
|
|
wait();
|
|
}
|
|
void stop();
|
|
bool connectTCP();
|
|
|
|
protected:
|
|
void run();
|
|
|
|
public:
|
|
void init(SyncQueue<_TCPSendInfo>* p_TCP_Info_queue, std::string ip_, int port_);
|
|
void start_work();
|
|
void sendData(_TCPSendInfo* TCPSendInfo, int Num);
|
|
|
|
public:
|
|
SyncQueue<_TCPSendInfo>* Local_TCP_Info_queue;
|
|
std::atomic_bool isLoop = { 0 };
|
|
QTcpSocket* mySocket;
|
|
};
|