mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:07:45 +00:00
telws: Port to LibMain
This commit is contained in:
parent
bb4994d67b
commit
234025ee53
2 changed files with 9 additions and 17 deletions
|
@ -194,7 +194,7 @@ target_link_libraries(tac LibMain)
|
||||||
target_link_libraries(tail LibMain)
|
target_link_libraries(tail LibMain)
|
||||||
target_link_libraries(tar LibMain LibArchive LibCompress)
|
target_link_libraries(tar LibMain LibArchive LibCompress)
|
||||||
target_link_libraries(tee LibMain)
|
target_link_libraries(tee LibMain)
|
||||||
target_link_libraries(telws LibProtocol LibLine)
|
target_link_libraries(telws LibProtocol LibLine LibMain)
|
||||||
target_link_libraries(test-fuzz LibCore LibGemini LibGfx LibHTTP LibIPC LibJS LibMarkdown LibShell)
|
target_link_libraries(test-fuzz LibCore LibGemini LibGfx LibHTTP LibIPC LibJS LibMarkdown LibShell)
|
||||||
target_link_libraries(test-imap LibIMAP LibMain)
|
target_link_libraries(test-imap LibIMAP LibMain)
|
||||||
target_link_libraries(test-pthread LibThreading)
|
target_link_libraries(test-pthread LibThreading)
|
||||||
|
|
|
@ -9,18 +9,15 @@
|
||||||
#include <AK/URL.h>
|
#include <AK/URL.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/EventLoop.h>
|
#include <LibCore/EventLoop.h>
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibCore/Notifier.h>
|
|
||||||
#include <LibLine/Editor.h>
|
#include <LibLine/Editor.h>
|
||||||
|
#include <LibMain/Main.h>
|
||||||
#include <LibProtocol/WebSocket.h>
|
#include <LibProtocol/WebSocket.h>
|
||||||
#include <LibProtocol/WebSocketClient.h>
|
#include <LibProtocol/WebSocketClient.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
if (pledge("stdio unix inet accept rpath wpath cpath fattr tty sigaction", nullptr) < 0) {
|
TRY(Core::System::pledge("stdio unix inet accept rpath wpath cpath fattr tty sigaction"));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
|
|
||||||
|
@ -30,7 +27,7 @@ int main(int argc, char** argv)
|
||||||
args_parser.add_positional_argument(url_string, "URL to connect to", "url", Core::ArgsParser::Required::Yes);
|
args_parser.add_positional_argument(url_string, "URL to connect to", "url", Core::ArgsParser::Required::Yes);
|
||||||
args_parser.add_option(origin, "URL to use as origin", "origin", 'o', "origin");
|
args_parser.add_option(origin, "URL to use as origin", "origin", 'o', "origin");
|
||||||
|
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
URL url(url_string);
|
URL url(url_string);
|
||||||
|
|
||||||
|
@ -44,6 +41,7 @@ int main(int argc, char** argv)
|
||||||
auto maybe_websocket_client = Protocol::WebSocketClient::try_create();
|
auto maybe_websocket_client = Protocol::WebSocketClient::try_create();
|
||||||
if (maybe_websocket_client.is_error()) {
|
if (maybe_websocket_client.is_error()) {
|
||||||
warnln("Failed to connect to the websocket server: {}\n", maybe_websocket_client.error());
|
warnln("Failed to connect to the websocket server: {}\n", maybe_websocket_client.error());
|
||||||
|
return maybe_websocket_client.release_error();
|
||||||
}
|
}
|
||||||
auto websocket_client = maybe_websocket_client.release_value();
|
auto websocket_client = maybe_websocket_client.release_value();
|
||||||
|
|
||||||
|
@ -76,15 +74,9 @@ int main(int argc, char** argv)
|
||||||
Core::EventLoop::current().quit(0);
|
Core::EventLoop::current().quit(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (pledge("stdio unix inet accept rpath wpath tty sigaction", nullptr) < 0) {
|
TRY(Core::System::pledge("stdio unix inet accept rpath wpath tty sigaction"));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unveil(nullptr, nullptr) < 0) {
|
TRY(Core::System::unveil(nullptr, nullptr));
|
||||||
perror("unveil");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
outln("Started server. Commands :");
|
outln("Started server. Commands :");
|
||||||
outln("- '<text>' send the text as message");
|
outln("- '<text>' send the text as message");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue