KDEGames
kmessageserver.cpp
28 connect(this, &KMessageServerSocket::newConnection, this, &KMessageServerSocket::slotNewConnection);
95 qCDebug(KDEGAMESPRIVATE_KGAME_LOG) << "CREATE(KMessageServer=" << this << ") cookie=" << d->mCookie << "sizeof(this)=" << sizeof(KMessageServer);
128 qCDebug(KDEGAMESPRIVATE_KGAME_LOG) << ": Now listening to port " << d->mServerSocket->serverPort();
129 connect(d->mServerSocket, &KMessageServerSocket::newClientConnected, this, &KMessageServer::addClient);
212 QDataStream(&msg, QIODevice::WriteOnly) << quint32(EVNT_CLIENT_DISCONNECTED) << client->id() << (qint8)broken;
262 for (QList<KMessageIO *>::iterator iter(d->mClientList.begin()); iter != d->mClientList.end(); ++iter)
317 for (QList<KMessageIO *>::iterator iter(d->mClientList.begin()); iter != d->mClientList.end(); ++iter)
This abstract base class represents one end of a message connections between two clients.
Definition kmessageio.h:44
virtual void send(const QByteArray &msg)=0
This slot sends the data block in /e msg to the connected object, that will emit /e received().
void connectionBroken()
This signal is emitted when the connection is closed.
void received(const QByteArray &msg)
This signal is emitted when /e send() on the connected KMessageIO object is called.
void removeClient(KMessageIO *io, bool broken)
Removes the KMessageIO object from the client list and deletes it.
Definition kmessageserver.cpp:202
void clientConnected(KMessageIO *client)
A new client connected to the game.
KMessageIO * findClient(quint32 no) const
Find the KMessageIO object to the given client number.
Definition kmessageserver.cpp:267
quint32 adminID() const
Returns the clientID of the admin, if there is a admin, 0 otherwise.
Definition kmessageserver.cpp:281
void setMaxClients(int maxnumber)
sets the maximum number of clients which can connect.
Definition kmessageserver.cpp:243
virtual void getReceivedMessage(const QByteArray &msg)
This slot receives all the messages from the KMessageIO::received signals.
Definition kmessageserver.cpp:335
quint16 serverPort() const
Returns the TCP/IP port number we are listening to for incoming connections.
Definition kmessageserver.cpp:133
void addClient(KMessageIO *)
Adds a new KMessageIO object to the communication server.
Definition kmessageserver.cpp:156
void setAdmin(quint32 adminID)
Sets the admin to a new client with the given ID.
Definition kmessageserver.cpp:286
virtual void processOneMessage()
This slot is called whenever there are elements in the message queue.
Definition kmessageserver.cpp:354
quint32 uniqueClientNumber() const
Definition kmessageserver.cpp:308
bool initNetwork(quint16 port=0)
Starts the Communication server to listen for incoming TCP/IP connections.
Definition kmessageserver.cpp:109
void messageReceived(const QByteArray &data, quint32 clientID, bool &unknown)
This signal is always emitted when a message from a client is received.
void connectionLost(KMessageIO *client)
A network connection got broken.
virtual void broadcastMessage(const QByteArray &msg)
Sends a message to all connected clients.
Definition kmessageserver.cpp:315
virtual void sendMessage(quint32 id, const QByteArray &msg)
Sends a message to a single client with the given ID.
Definition kmessageserver.cpp:321
KMessageServer(quint16 cookie=42, QObject *parent=nullptr)
Create a KGameNetwork object.
Definition kmessageserver.cpp:89
bool isOfferingConnections() const
Are we still offer offering server connections?
Definition kmessageserver.cpp:149
QList< quint32 > clientIDs() const
returns a list of the unique IDs of all clients.
Definition kmessageserver.cpp:258
int clientCount() const
returns the current number of connected clients.
Definition kmessageserver.cpp:253
This class implements the message communication using a TCP/IP socket.
Definition kmessageio.h:150
virtual bool atEnd() const const override
virtual bool open(OpenMode flags) override
QByteArray readAll()
WriteOnly
void append(QList< T > &&value)
void reserve(qsizetype size)
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
T qobject_cast(QObject *object)
QObject * sender() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void timeout()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:04 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:04 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.