6 #include <QLocalSocket> 10 using ClientSocketId = qulonglong;
18 QLocalSocket *
get()
const {
return m_socket; }
19 QLocalSocket *operator->()
const {
return m_socket; }
20 operator QLocalSocket*() {
return m_socket; }
21 operator bool() {
return !m_socket.isNull(); }
27 QPointer<QLocalSocket> m_socket;
36 explicit ClientSocket(
const QString &serverName, QObject *parent =
nullptr);
38 explicit ClientSocket(QLocalSocket *socket, QObject *parent =
nullptr);
43 ClientSocketId
id()
const {
return m_socketId; }
50 const QByteArray &message,
57 void messageReceived(
const QByteArray &message,
int messageCode, ClientSocketId clientId);
58 void disconnected(ClientSocketId clientId);
59 void connectionFailed(ClientSocketId clientId);
63 void onError(QLocalSocket::LocalSocketError error);
64 void onStateChanged(QLocalSocket::LocalSocketState state);
66 void error(
const QString &errorMessage);
69 ClientSocketId m_socketId;
72 bool m_hasMessageLength =
false;
73 quint32 m_messageLength = 0;
77 #endif // CLIENTSOCKET_H Definition: clientsocket.h:12
Definition: clientsocket.h:30
ClientSocketId id() const
Return socket ID unique in process (thread-safe).
Definition: clientsocket.h:43