From f74898e2cf801fb4d8c20de4980c975f3d87c571 Mon Sep 17 00:00:00 2001 From: Karchnu Date: Mon, 20 Jul 2020 22:52:38 +0200 Subject: [PATCH] print state --- src/websocketd.cr | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/websocketd.cr b/src/websocketd.cr index 27b63df..6a0925a 100644 --- a/src/websocketd.cr +++ b/src/websocketd.cr @@ -282,6 +282,7 @@ def main server = TCPServer.new(CLI.host, CLI.port_to_listen) service = IPC::Server.new CLI.service_name service << server.fd + # Every few seconds, the service should trigger the timer # Allowing the sending of Ping messages to clients service.base_timer = CLI.timer_delay @@ -289,11 +290,12 @@ def main service.loop do |event| # info "current state of the context:" - # service.pp + service.pp case event when IPC::Event::Timer info "#{CORANGE}IPC::Event::Timer#{CRESET}" sending_ping_messages + when IPC::Event::Connection info "#{CBLUE}IPC::Event::Connection#{CRESET}: #{event.fd}" when IPC::Event::Disconnection @@ -301,16 +303,13 @@ def main Context.context.remove_fd event.fd when IPC::Event::ExtraSocket info "#{CBLUE}IPC::Event::ExtraSocket#{CRESET}: #{event.fd}" - if server.fd != event.fd raise "Error: the only extra socket should be the TCP/WS server" end - handle_new_clients(service, server) when IPC::Event::Switch info "\033[36mIPC::Event::Switch#{CRESET}: from fd #{event.fd}" - # raise "Not implemented." when IPC::Event::MessageSent