1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 22:38:12 +00:00
serenity/Libraries/LibProtocol/Client.h
Andreas Kling fd4349a9f2 ProtocolServer+LibProtocol: Introduce a server for handling downloads
This patch adds ProtocolServer, a server that handles network requests
on behalf of its clients. The first protocol implemented is HTTP.

The idea here is to use a plug-in architecture where any number of
protocols can be added and implemented without having to mess around
with each client program that wants to use the protocol.

A simple client API is provided through LibProtocol::Client. :^)
2019-11-23 21:50:32 +01:00

29 lines
858 B
C++

#pragma once
#include <LibCore/CoreIPCClient.h>
#include <ProtocolServer/ProtocolClientEndpoint.h>
#include <ProtocolServer/ProtocolServerEndpoint.h>
namespace LibProtocol {
class Client : public IPC::Client::ConnectionNG<ProtocolClientEndpoint, ProtocolServerEndpoint>
, public ProtocolClientEndpoint {
C_OBJECT(Client)
public:
Client();
virtual void handshake() override;
bool is_supported_protocol(const String&);
i32 start_download(const String& url);
bool stop_download(i32 download_id);
Function<void(i32 download_id, bool success)> on_download_finish;
Function<void(i32 download_id, u64 total_size, u64 downloaded_size)> on_download_progress;
private:
virtual void handle(const ProtocolClient::DownloadProgress&) override;
virtual void handle(const ProtocolClient::DownloadFinished&) override;
};
}