| 
									
										
										
										
											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; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool is_listening() const { return m_listening; } | 
					
						
							|  |  |  |     bool listen(const String& address); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-21 10:28:02 +02:00
										 |  |  |     ObjectPtr<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-07-27 10:21:25 +02:00
										 |  |  |     int m_fd { -1 }; | 
					
						
							|  |  |  |     bool m_listening { false }; | 
					
						
							| 
									
										
										
										
											2019-09-20 15:39:15 +02:00
										 |  |  |     ObjectPtr<CNotifier> m_notifier; | 
					
						
							| 
									
										
										
										
											2019-07-27 10:21:25 +02:00
										 |  |  | }; |