/* * Copyright (c) 2018-2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include "Command.h" #include "Parser.h" class Client : public RefCounted { public: static ErrorOr> create(int id, NonnullOwnPtr socket, int ptm_fd); Function on_exit; private: Client(int id, NonnullOwnPtr socket, int ptm_fd); ErrorOr drain_socket(); ErrorOr drain_pty(); ErrorOr handle_command(Command const& command); ErrorOr send_data(StringView str); ErrorOr send_command(Command command); ErrorOr send_commands(Vector commands); void handle_data(StringView); void handle_error(); void quit(); // client id int m_id { 0 }; // client resources NonnullOwnPtr m_socket; Parser m_parser; // pty resources int m_ptm_fd { -1 }; RefPtr m_ptm_notifier; };