2019-07-27 10:21:25 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibCore/CNotifier.h>
|
|
|
|
#include <LibCore/CObject.h>
|
|
|
|
|
|
|
|
class CLocalSocket;
|
|
|
|
|
|
|
|
class CLocalServer : public CObject {
|
|
|
|
C_OBJECT(CLocalServer)
|
|
|
|
public:
|
|
|
|
virtual ~CLocalServer() override;
|
|
|
|
|
2019-11-26 19:27:21 +03:00
|
|
|
bool take_over_from_system_server();
|
2019-07-27 10:21:25 +02:00
|
|
|
bool is_listening() const { return m_listening; }
|
|
|
|
bool listen(const String& address);
|
|
|
|
|
2019-09-22 00:31:54 +02:00
|
|
|
RefPtr<CLocalSocket> accept();
|
2019-07-27 10:21:25 +02:00
|
|
|
|
|
|
|
Function<void()> on_ready_to_accept;
|
|
|
|
|
|
|
|
private:
|
2019-09-21 10:46:55 +02:00
|
|
|
explicit CLocalServer(CObject* parent = nullptr);
|
|
|
|
|
2019-11-26 19:27:21 +03:00
|
|
|
void setup_notifier();
|
|
|
|
|
2019-07-27 10:21:25 +02:00
|
|
|
int m_fd { -1 };
|
|
|
|
bool m_listening { false };
|
2019-09-22 00:31:54 +02:00
|
|
|
RefPtr<CNotifier> m_notifier;
|
2019-07-27 10:21:25 +02:00
|
|
|
};
|