mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:17:46 +00:00
telws: Port to LibMain
This commit is contained in:
parent
bb4994d67b
commit
234025ee53
2 changed files with 9 additions and 17 deletions
|
@ -9,18 +9,15 @@
|
|||
#include <AK/URL.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibLine/Editor.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <LibProtocol/WebSocket.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) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::pledge("stdio unix inet accept rpath wpath cpath fattr tty sigaction"));
|
||||
|
||||
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_option(origin, "URL to use as origin", "origin", 'o', "origin");
|
||||
|
||||
args_parser.parse(argc, argv);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
URL url(url_string);
|
||||
|
||||
|
@ -44,6 +41,7 @@ int main(int argc, char** argv)
|
|||
auto maybe_websocket_client = Protocol::WebSocketClient::try_create();
|
||||
if (maybe_websocket_client.is_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();
|
||||
|
||||
|
@ -76,15 +74,9 @@ int main(int argc, char** argv)
|
|||
Core::EventLoop::current().quit(0);
|
||||
};
|
||||
|
||||
if (pledge("stdio unix inet accept rpath wpath tty sigaction", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::pledge("stdio unix inet accept rpath wpath tty sigaction"));
|
||||
|
||||
if (unveil(nullptr, nullptr) < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
outln("Started server. Commands :");
|
||||
outln("- '<text>' send the text as message");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue