diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-09-21 15:18:12 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-09-21 15:25:08 +0200 |
commit | 4ea229accdac70e418af8f3f6d57cb5797d5dfad (patch) | |
tree | 7f9d4b348dc766d8fde9cd936b6b2a55d7e7ae77 /Servers/TelnetServer | |
parent | bce58bbbca6086270e74b32ee63435ca7bf2b0fb (diff) | |
download | serenity-4ea229accdac70e418af8f3f6d57cb5797d5dfad.zip |
LibCore: Convert CTCPServer to ObjectPtr
Also get rid of the custom CNotifier::create() in favor of construct().
Diffstat (limited to 'Servers/TelnetServer')
-rw-r--r-- | Servers/TelnetServer/Client.cpp | 2 | ||||
-rw-r--r-- | Servers/TelnetServer/main.cpp | 14 |
2 files changed, 8 insertions, 8 deletions
diff --git a/Servers/TelnetServer/Client.cpp b/Servers/TelnetServer/Client.cpp index a813849a47..5130ca7371 100644 --- a/Servers/TelnetServer/Client.cpp +++ b/Servers/TelnetServer/Client.cpp @@ -14,7 +14,7 @@ Client::Client(int id, ObjectPtr<CTCPSocket> socket, int ptm_fd) : m_id(id) , m_socket(move(socket)) , m_ptm_fd(ptm_fd) - , m_ptm_notifier(CNotifier::create(ptm_fd, CNotifier::Read)) + , m_ptm_notifier(CNotifier::construct(ptm_fd, CNotifier::Read)) { m_socket->on_ready_to_read = [this] { drain_socket(); }; m_ptm_notifier->on_ready_to_read = [this] { drain_pty(); }; diff --git a/Servers/TelnetServer/main.cpp b/Servers/TelnetServer/main.cpp index e932fccad7..dee7efb29c 100644 --- a/Servers/TelnetServer/main.cpp +++ b/Servers/TelnetServer/main.cpp @@ -1,3 +1,4 @@ +#include "Client.h" #include <AK/BufferStream.h> #include <AK/ByteBuffer.h> #include <AK/HashMap.h> @@ -11,10 +12,9 @@ #include <fcntl.h> #include <getopt.h> #include <stdio.h> +#include <stdlib.h> #include <sys/ioctl.h> -#include "Client.h" - static void run_command(int ptm_fd, String command) { pid_t pid = fork(); @@ -81,7 +81,7 @@ static void run_command(int ptm_fd, String command) int main(int argc, char** argv) { CEventLoop event_loop; - CTCPServer server; + auto server = CTCPServer::construct(); int opt; u16 port = 23; @@ -96,7 +96,7 @@ int main(int argc, char** argv) } } - if (!server.listen({}, port)) { + if (!server->listen({}, port)) { perror("listen"); exit(1); } @@ -104,10 +104,10 @@ int main(int argc, char** argv) HashMap<int, NonnullRefPtr<Client>> clients; int next_id = 0; - server.on_ready_to_accept = [&next_id, &clients, &server] { + server->on_ready_to_accept = [&next_id, &clients, &server] { int id = next_id++; - auto client_socket = server.accept(); + auto client_socket = server->accept(); if (!client_socket) { perror("accept"); return; @@ -122,7 +122,7 @@ int main(int argc, char** argv) run_command(ptm_fd, ""); - auto client = Client::create(id, client_socket, ptm_fd); + auto client = Client::create(id, move(client_socket), ptm_fd); client->on_exit = [&clients, id] { clients.remove(id); }; clients.set(id, client); }; |