3#include <QAbstractSocket>
47 bool send_data(
const QByteArray& raw_data);
59 const QString
uuid()
const {
return uuid_marker; }
100 void handleNewConnection();
105 void onSocketStateChanged(QAbstractSocket::SocketState socketState);
110 void onSocketError(QAbstractSocket::SocketError socketError);
114 void processSocketRead();
121 void setupSocket(QTcpSocket* socket);
128 QTcpServer* server_socket {};
129 QTcpSocket* peer_socket {};
132 const QString uuid_marker;
socket positive
Definition PeerConnection.h:8
void bytesWritten(qint64 bytesWritten)
Emitted to report the result of a send operation.
ConnectionState state() const
Returns the current state of the connection.
Definition PeerConnection.cpp:69
ConnectionState
Defines the current state of the peer connection.
Definition PeerConnection.h:15
@ Connected
An active connection is established.
@ Listening
Listening for an incoming connection.
@ Connecting
Attempting to connect to a peer.
@ Disconnected
No active connection.
bool availableSelfListen(const SelfInfo &info)
listen for the P2P available
Definition PeerConnection.cpp:17
void errorOccurred(QAbstractSocket::SocketError socketError)
Emitted when a network error occurs.
void stateChanged(PeerConnection::ConnectionState state)
Emitted when the connection state changes.
PeerInfo peerInfo() const
Gets the information of the connected remote peer.
Definition PeerConnection.cpp:65
void connected()
Emitted when a connection is successfully established.
void disconnectFromPeer()
Closes the current connection and stops listening. Resets the object to its initial state.
Definition PeerConnection.cpp:83
void disconnected()
Emitted when the connection is terminated.
void dataReceived(const QByteArray &data)
Emitted when data is received from the peer.
bool send_data(const QByteArray &raw_data)
Asynchronously sends data to the connected peer.
Definition PeerConnection.cpp:73
const QString uuid() const
get the only one uuid
Definition PeerConnection.h:59