mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 14:05:15 +00:00
This is to prepare for an upcoming change where we will need to track replies to messages by ID. We will be able to add parameters to this structure without having to edit every single actor subclass header file.
38 lines
856 B
C++
38 lines
856 B
C++
/*
|
|
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Error.h>
|
|
#include <AK/Function.h>
|
|
#include <AK/NonnullOwnPtr.h>
|
|
#include <AK/NonnullRefPtr.h>
|
|
#include <AK/RefCounted.h>
|
|
#include <LibCore/Socket.h>
|
|
#include <LibDevTools/Forward.h>
|
|
|
|
namespace DevTools {
|
|
|
|
class Connection : public RefCounted<Connection> {
|
|
public:
|
|
static NonnullRefPtr<Connection> create(NonnullOwnPtr<Core::BufferedTCPSocket>);
|
|
~Connection();
|
|
|
|
Function<void()> on_connection_closed;
|
|
Function<void(JsonObject)> on_message_received;
|
|
|
|
void send_message(JsonValue const&);
|
|
|
|
private:
|
|
explicit Connection(NonnullOwnPtr<Core::BufferedTCPSocket>);
|
|
|
|
ErrorOr<void> on_ready_to_read();
|
|
ErrorOr<JsonValue> read_message();
|
|
|
|
NonnullOwnPtr<Core::BufferedTCPSocket> m_socket;
|
|
};
|
|
|
|
}
|