mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
pro: Add a little userland utility for testing ProtocolServer
This commit is contained in:
parent
fd4349a9f2
commit
88c5126fa7
Notes:
sideshowbarker
2024-07-19 11:06:06 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/88c5126fa72
2 changed files with 30 additions and 1 deletions
|
@ -19,7 +19,7 @@ clean:
|
|||
|
||||
$(APPS) : % : %.o $(OBJS)
|
||||
@echo "LD $@"
|
||||
@$(LD) -o $@ $(LDFLAGS) $< -lc -lhtml -lgui -ldraw -laudio -lipc -lthread -lcore -lpcidb -lmarkdown -lpthread
|
||||
@$(LD) -o $@ $(LDFLAGS) $< -lc -lhtml -lgui -ldraw -laudio -lipc -lthread -lcore -lpcidb -lmarkdown -lpthread -lprotocol -lipc
|
||||
|
||||
%.o: %.cpp
|
||||
@echo "CXX $<"
|
||||
|
|
29
Userland/pro.cpp
Normal file
29
Userland/pro.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include <LibCore/CEventLoop.h>
|
||||
#include <LibProtocol/Client.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
CEventLoop loop;
|
||||
auto protocol_client = LibProtocol::Client::construct();
|
||||
protocol_client->handshake();
|
||||
|
||||
printf("supports HTTP? %u\n", protocol_client->is_supported_protocol("http"));
|
||||
printf(" supports FTP? %u\n", protocol_client->is_supported_protocol("ftp"));
|
||||
|
||||
protocol_client->on_download_finish = [&](i32 download_id, bool success) {
|
||||
printf("download %d finished, success=%u\n", download_id, success);
|
||||
loop.quit(0);
|
||||
};
|
||||
|
||||
protocol_client->on_download_progress = [&](i32 download_id, u32 total_size, u32 downloaded_size) {
|
||||
printf("download %d progress: %u / %u\n", download_id, downloaded_size, total_size);
|
||||
};
|
||||
|
||||
i32 download_id = protocol_client->start_download("http://192.168.1.21/");
|
||||
printf("started download with id %d\n", download_id);
|
||||
|
||||
return loop.exec();
|
||||
}
|
Loading…
Add table
Reference in a new issue