mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 14:54:59 +00:00

This makes it more symmetrical with adopt_own() (which is used to create a NonnullOwnPtr from the result of a naked new.)
29 lines
557 B
C++
29 lines
557 B
C++
/*
|
|
* 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;
|
|
};
|