KMessageSocket
#include <KGame/KMessageIO>
Public Member Functions | |
KMessageSocket (const QHostAddress &host, quint16 port, QObject *parent=nullptr) | |
KMessageSocket (const QString &host, quint16 port, QObject *parent=nullptr) | |
KMessageSocket (int socketFD, QObject *parent=nullptr) | |
KMessageSocket (QTcpSocket *socket, QObject *parent=nullptr) | |
~KMessageSocket () override | |
bool | isConnected () const override |
bool | isNetwork () const override |
QString | peerName () const override |
quint16 | peerPort () const override |
int | rtti () const override |
void | send (const QByteArray &msg) override |
Public Member Functions inherited from KMessageIO | |
KMessageIO (QObject *parent=nullptr) | |
~KMessageIO () override | |
quint32 | id () |
void | setId (quint32 id) |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QBindable< QString > | bindableObjectName () |
bool | blockSignals (bool block) |
const QObjectList & | children () const const |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectInfo () const const |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isQuickItemType () const const |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_GADGET_EXPORT (EXPORT_MACRO) | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_MOC_INCLUDE Q_MOC_INCLUDE | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_OBJECT Q_OBJECT | |
Q_PROPERTY (...) | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
Q_SIGNAL Q_SIGNAL | |
Q_SIGNALS Q_SIGNALS | |
Q_SLOT Q_SLOT | |
Q_SLOTS Q_SLOTS | |
T | qobject_cast (const QObject *object) |
T | qobject_cast (QObject *object) |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setObjectName (QAnyStringView name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | setProperty (const char *name, QVariant &&value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType) |
QThread * | thread () const const |
Protected Slots | |
virtual void | processNewData () |
Protected Member Functions | |
void | initSocket () |
Protected Member Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Protected Attributes | |
bool | isRecursive |
bool | mAwaitingHeader |
quint32 | mNextBlockLength |
QTcpSocket * | mSocket |
Protected Attributes inherited from KMessageIO | |
quint32 | m_id |
Additional Inherited Members | |
Public Types inherited from QObject | |
typedef | QObjectList |
Properties inherited from QObject | |
objectName | |
Signals inherited from KMessageIO | |
void | connectionBroken () |
void | received (const QByteArray &msg) |
Public Slots inherited from KMessageIO | |
Static Public Member Functions inherited from QObject | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
Detailed Description
This class implements the message communication using a TCP/IP socket.
The object can connect to a server socket, or can use an already connected socket.
Definition at line 149 of file kmessageio.h.
Constructor & Destructor Documentation
◆ KMessageSocket() [1/4]
Connects to a server socket on /e host with /e port.
host can be an numerical (e.g. "192.168.0.212") or symbolic (e.g. "wave.peter.org") IP address. You can immediately use the /e sendSystem() and /e sendBroadcast() methods. The messages are stored and sent to the receiver after the connection is established.
If the connection could not be established (e.g. unknown host or no server socket at this port), the signal /e connectionBroken is emitted.
Definition at line 67 of file kmessageio.cpp.
◆ KMessageSocket() [2/4]
KMessageSocket::KMessageSocket | ( | const QHostAddress & | host, |
quint16 | port, | ||
QObject * | parent = nullptr ) |
Connects to a server socket on /e host with /e port.
You can immediately use the /e sendSystem() and /e sendBroadcast() methods. The messages are stored and sent to the receiver after the connection is established.
If the connection could not be established (e.g. unknown host or no server socket at this port), the signal /e connectionBroken is emitted.
Definition at line 75 of file kmessageio.cpp.
◆ KMessageSocket() [3/4]
|
explicit |
Uses /e socket to do the communication.
The socket should already be connected, or at least be in /e connecting state.
Note: The /e socket object is then owned by the /e KMessageSocket object. So don't use it otherwise any more and don't delete it. It is deleted together with this KMessageSocket object. (Use 0 as parent for the QSocket object t ensure it is not deleted.)
Definition at line 83 of file kmessageio.cpp.
◆ KMessageSocket() [4/4]
|
explicit |
Uses the socket specified by the socket descriptor socketFD to do the communication.
The socket must already be connected.
This constructor can be used with a QServerSocket within the (pure virtual) method /e newConnection.
Note: The socket is then owned by the /e KMessageSocket object. So don't manipulate the socket afterwards, especially don't close it. The socket is automatically closed when KMessageSocket is deleted.
Definition at line 90 of file kmessageio.cpp.
◆ ~KMessageSocket()
|
override |
Destructor, closes the socket.
Definition at line 98 of file kmessageio.cpp.
Member Function Documentation
◆ initSocket()
|
protected |
Definition at line 163 of file kmessageio.cpp.
◆ isConnected()
|
overridevirtual |
Returns true if the socket is in state /e connected.
Reimplemented from KMessageIO.
Definition at line 103 of file kmessageio.cpp.
◆ isNetwork()
|
inlineoverridevirtual |
- Returns
- TRUE as this is a network IO.
Reimplemented from KMessageIO.
Definition at line 228 of file kmessageio.h.
◆ peerName()
|
overridevirtual |
- Returns
- The hostname this object is connected to. See QSocket::peerName.
Reimplemented from KMessageIO.
Definition at line 178 of file kmessageio.cpp.
◆ peerPort()
|
overridevirtual |
- Returns
- The port that this object is connected to. See QSocket::peerPort
Reimplemented from KMessageIO.
Definition at line 173 of file kmessageio.cpp.
◆ processNewData
|
protectedvirtualslot |
Definition at line 115 of file kmessageio.cpp.
◆ rtti()
|
inlineoverridevirtual |
The runtime identification.
Reimplemented from KMessageIO.
Definition at line 210 of file kmessageio.h.
◆ send()
|
overridevirtual |
Overwritten slot method from KMessageIO.
Note: It is not declared as a slot method, since the slot is already defined in KMessageIO as a virtual method.
Implements KMessageIO.
Definition at line 108 of file kmessageio.cpp.
Member Data Documentation
◆ isRecursive
|
protected |
Definition at line 255 of file kmessageio.h.
◆ mAwaitingHeader
|
protected |
Definition at line 252 of file kmessageio.h.
◆ mNextBlockLength
|
protected |
Definition at line 253 of file kmessageio.h.
◆ mSocket
|
protected |
Definition at line 251 of file kmessageio.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:09:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.