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.
49 lines
1.5 KiB
C
49 lines
1.5 KiB
C
|
4 years ago
|
#ifndef LIBTCPSERVER_H
|
||
|
|
#define LIBTCPSERVER_H
|
||
|
|
|
||
|
|
#include <QtCore/qglobal.h>
|
||
|
|
|
||
|
|
//#if defined(LIBTCPSERVER_LIBRARY)
|
||
|
|
//# define LIBTCPSERVERSHARED_EXPORT Q_DECL_EXPORT
|
||
|
|
//#else
|
||
|
|
# define LIBTCPSERVERSHARED_EXPORT Q_DECL_IMPORT
|
||
|
|
//#endif
|
||
|
|
|
||
|
|
#include "libTcp.h"
|
||
|
|
#include <QTcpServer>
|
||
|
|
|
||
|
|
class TPTcpServer;
|
||
|
|
|
||
|
|
class lpTcpServer : public QObject
|
||
|
|
{
|
||
|
|
Q_OBJECT
|
||
|
|
|
||
|
|
public:
|
||
|
|
lpTcpServer(const TP_TCP_SERVER_PARAM& init_param,
|
||
|
|
QObject *parent = 0);
|
||
|
|
~lpTcpServer();
|
||
|
|
|
||
|
|
ClientsStatusMap IGetClientsStatus();
|
||
|
|
const TpServerStatus IGetServerStatus() { return server_status_; }
|
||
|
|
|
||
|
|
void IGetVersion(QString& version);
|
||
|
|
bool IStartServer();
|
||
|
|
void IStopServer();
|
||
|
|
void ISendMessage(const QString& strClient, TP_PROTOCOL_MESSAGE& msg);
|
||
|
|
void ISendBinaryData(const QString& strClient, TP_PROTOCOL_MESSAGE& msg, QByteArray& binaryData);
|
||
|
|
signals:
|
||
|
|
void signal_client_connected(const QString&);
|
||
|
|
void signal_client_disconnected(const QString&);
|
||
|
|
|
||
|
|
void signal_message_received(const QString&, QSharedPointer<TP_PROTOCOL_MESSAGE>);
|
||
|
|
void signal_data_send_completed(QSharedPointer<TP_PROTOCOL_MESSAGE>);
|
||
|
|
void signal_data_recv_completed(const QString& , QSharedPointer<TP_PROTOCOL_MESSAGE>, QSharedPointer<QByteArray> );
|
||
|
|
void signal_data_recv_completed_client(QSharedPointer<TP_PROTOCOL_MESSAGE>, QSharedPointer<QByteArray>);
|
||
|
|
private:
|
||
|
|
QSharedPointer<TPTcpServer> tcp_server_{nullptr};
|
||
|
|
QHostAddress listen_addr_;
|
||
|
|
quint16 listen_port_;
|
||
|
|
TpServerStatus server_status_;
|
||
|
|
};
|
||
|
|
#endif // LIBTCPSERVER_H
|