3
0
Fork 0

print state

dev
Karchnu 2020-07-20 22:52:38 +02:00
parent d45d254d41
commit f74898e2cf
1 changed files with 3 additions and 4 deletions

View File

@ -282,6 +282,7 @@ def main
server = TCPServer.new(CLI.host, CLI.port_to_listen) server = TCPServer.new(CLI.host, CLI.port_to_listen)
service = IPC::Server.new CLI.service_name service = IPC::Server.new CLI.service_name
service << server.fd service << server.fd
# Every few seconds, the service should trigger the timer # Every few seconds, the service should trigger the timer
# Allowing the sending of Ping messages to clients # Allowing the sending of Ping messages to clients
service.base_timer = CLI.timer_delay service.base_timer = CLI.timer_delay
@ -289,11 +290,12 @@ def main
service.loop do |event| service.loop do |event|
# info "current state of the context:" # info "current state of the context:"
# service.pp service.pp
case event case event
when IPC::Event::Timer when IPC::Event::Timer
info "#{CORANGE}IPC::Event::Timer#{CRESET}" info "#{CORANGE}IPC::Event::Timer#{CRESET}"
sending_ping_messages sending_ping_messages
when IPC::Event::Connection when IPC::Event::Connection
info "#{CBLUE}IPC::Event::Connection#{CRESET}: #{event.fd}" info "#{CBLUE}IPC::Event::Connection#{CRESET}: #{event.fd}"
when IPC::Event::Disconnection when IPC::Event::Disconnection
@ -301,16 +303,13 @@ def main
Context.context.remove_fd event.fd Context.context.remove_fd event.fd
when IPC::Event::ExtraSocket when IPC::Event::ExtraSocket
info "#{CBLUE}IPC::Event::ExtraSocket#{CRESET}: #{event.fd}" info "#{CBLUE}IPC::Event::ExtraSocket#{CRESET}: #{event.fd}"
if server.fd != event.fd if server.fd != event.fd
raise "Error: the only extra socket should be the TCP/WS server" raise "Error: the only extra socket should be the TCP/WS server"
end end
handle_new_clients(service, server) handle_new_clients(service, server)
when IPC::Event::Switch when IPC::Event::Switch
info "\033[36mIPC::Event::Switch#{CRESET}: from fd #{event.fd}" info "\033[36mIPC::Event::Switch#{CRESET}: from fd #{event.fd}"
# raise "Not implemented." # raise "Not implemented."
when IPC::Event::MessageSent when IPC::Event::MessageSent