opuntiaOS - an operating system targeting x86 and ARMv7
at master 1.3 kB view raw
1/* 2 * Copyright (C) 2020-2022 The opuntiaOS Project Authors. 3 * + Contributed by Nikita Melekhin <nimelehin@gmail.com> 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9#pragma once 10#include "../../shared/Connections/WSConnection.h" 11#include "ServerDecoder.h" 12#include <libfoundation/EventReceiver.h> 13#include <libipc/ServerConnection.h> 14 15namespace WinServer { 16 17class Connection : public LFoundation::EventReceiver { 18public: 19 inline static Connection& the() 20 { 21 extern Connection* s_WinServer_Connection_the; 22 return *s_WinServer_Connection_the; 23 } 24 25 explicit Connection(int connection_fd); 26 27 inline void listen() 28 { 29 m_connection_with_clients.pump_messages(); 30 } 31 32 inline bool send_async_message(const Message& msg) const { return m_connection_with_clients.send_message(msg); } 33 inline int alloc_connection() { return ++m_connections_number; } 34 void receive_event(std::unique_ptr<LFoundation::Event> event) override; 35 36private: 37 int m_connection_fd; 38 int m_connections_number { 0 }; 39 ServerConnection<WindowServerDecoder, BaseWindowClientDecoder> m_connection_with_clients; 40 WindowServerDecoder m_server_decoder; 41 BaseWindowClientDecoder m_client_decoder; 42}; 43 44} // namespace WinServer