forked from quickshell/quickshell
io/socket: add flush()
This commit is contained in:
parent
a06af243ad
commit
23d0c2e01d
2 changed files with 26 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <qlocalserver.h>
|
||||
#include <qlocalsocket.h>
|
||||
#include <qloggingcategory.h>
|
||||
#include <qobject.h>
|
||||
#include <qqmlcomponent.h>
|
||||
#include <qqmlintegration.h>
|
||||
|
@ -11,6 +12,8 @@
|
|||
#include "../core/reload.hpp"
|
||||
#include "datastream.hpp"
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(logSocket);
|
||||
|
||||
///! Unix socket listener.
|
||||
class Socket: public DataStream {
|
||||
Q_OBJECT;
|
||||
|
@ -30,8 +33,13 @@ public:
|
|||
explicit Socket(QObject* parent = nullptr): DataStream(parent) {}
|
||||
|
||||
/// Write data to the socket. Does nothing if not connected.
|
||||
///
|
||||
/// Remember to call flush after your last write.
|
||||
Q_INVOKABLE void write(const QString& data);
|
||||
|
||||
/// Flush any queued writes to the socket.
|
||||
Q_INVOKABLE void flush();
|
||||
|
||||
// takes ownership
|
||||
void setSocket(QLocalSocket* socket);
|
||||
|
||||
|
@ -54,6 +62,7 @@ protected:
|
|||
private slots:
|
||||
void onSocketConnected();
|
||||
void onSocketDisconnected();
|
||||
void onSocketError(QLocalSocket::LocalSocketError error);
|
||||
|
||||
private:
|
||||
void connectPathSocket();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue