summaryrefslogtreecommitdiff
path: root/Userland/Services/EchoServer/Client.h
blob: d9c30768810af0dae74f64421178b65207313de3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
 * Copyright (c) 2020, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibCore/TCPSocket.h>

class Client : public RefCounted<Client> {
public:
    static NonnullRefPtr<Client> create(int id, RefPtr<Core::TCPSocket> socket)
    {
        return adopt_ref(*new Client(id, move(socket)));
    }

    Function<void()> on_exit;

protected:
    Client(int id, RefPtr<Core::TCPSocket> socket);

    void drain_socket();
    void quit();

private:
    int m_id { 0 };
    RefPtr<Core::TCPSocket> m_socket;
};