Banking_System_Client  1.0.0
Qt-based banking app for user/admin account management, transactions, secure server communication via PostgreSQL/Supabase.
tcpclient.h
Go to the documentation of this file.
1 
9 #ifndef TCPCLIENT_H
10 #define TCPCLIENT_H
11 
12 #include <QObject>
13 #include <QTcpSocket>
14 #include <QSslSocket>
15 #include <QJsonObject>
16 #include <QJsonDocument>
17 #include <QDebug>
18 
27 class TcpClient : public QObject
28 {
29  Q_OBJECT
30 public:
37  explicit TcpClient(QObject* parent = nullptr);
38 
44  ~TcpClient();
45 
53  void connectToServer(const QString& host, quint16 port);
54 
61  void sendTcpRequest(const QByteArray& request);
62 
68  void closeConnection();
69 
70 signals:
75  void ResponseReadySignal(QByteArray response);
76 
81 
86 
87 private slots:
93  void onConnected();
94 
100  void onReadyRead();
101 
108  void onErrorOccurred(QAbstractSocket::SocketError socketError);
109 
116  void onStateChanged(QAbstractSocket::SocketState socketState);
117 
123  void onDisconnected();
124 
125 private:
126  QTcpSocket* socket;
127 };
128 
129 #endif // TCPCLIENT_H
A class for managing TCP client connections.
Definition: tcpclient.h:28
~TcpClient()
Destructor for TcpClient.
Definition: tcpclient.cpp:34
TcpClient(QObject *parent=nullptr)
Constructor for TcpClient.
Definition: tcpclient.cpp:21
void closeConnection()
Close the TCP connection.
Definition: tcpclient.cpp:65
void ResponseReadySignal(QByteArray response)
Signal emitted when a response is ready.
void connectToServer(const QString &host, quint16 port)
Connect to a TCP server.
Definition: tcpclient.cpp:39
void sendTcpRequest(const QByteArray &request)
Send a TCP request.
Definition: tcpclient.cpp:46
void ConnectedSignal()
Signal emitted when connected to the server.
void DisconnectedSignal()
Signal emitted when disconnected from the server.