mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:37:35 +00:00
LibCore+Userland: Convert TCPServer to use the Serenity Stream API
This is intended as a real-usecase test of the Serenity Stream API, and seemed like a good candidate due to its low amount of users.
This commit is contained in:
parent
2341b0159a
commit
dfdb52efa7
11 changed files with 263 additions and 124 deletions
|
@ -6,11 +6,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibCore/TCPSocket.h>
|
||||
#include <LibCore/Stream.h>
|
||||
|
||||
class Client : public RefCounted<Client> {
|
||||
public:
|
||||
static NonnullRefPtr<Client> create(int id, RefPtr<Core::TCPSocket> socket)
|
||||
static NonnullRefPtr<Client> create(int id, Core::Stream::TCPSocket socket)
|
||||
{
|
||||
return adopt_ref(*new Client(id, move(socket)));
|
||||
}
|
||||
|
@ -18,12 +18,12 @@ public:
|
|||
Function<void()> on_exit;
|
||||
|
||||
protected:
|
||||
Client(int id, RefPtr<Core::TCPSocket> socket);
|
||||
Client(int id, Core::Stream::TCPSocket socket);
|
||||
|
||||
void drain_socket();
|
||||
ErrorOr<void> drain_socket();
|
||||
void quit();
|
||||
|
||||
private:
|
||||
int m_id { 0 };
|
||||
RefPtr<Core::TCPSocket> m_socket;
|
||||
Core::Stream::TCPSocket m_socket;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue