Archived
3
0

Final catch for the IPC loop.

This commit is contained in:
Karchnu 2020-08-26 16:50:14 +02:00
parent 6a5496a393
commit 185a87431c

View File

@ -382,50 +382,54 @@ end
Context.service.base_timer = Context.timer_delay
Context.service.loop do |event|
case event
when IPC::Event::Timer
Log.info "IPC::Event::Timer"
sending_ping_messages
when IPC::Event::Connection
Log.debug "IPC::Event::Connection: #{event.fd}"
begin
case event
when IPC::Event::Timer
Log.info "IPC::Event::Timer"
sending_ping_messages
when IPC::Event::Connection
Log.debug "IPC::Event::Connection: #{event.fd}"
when IPC::Event::Disconnection
Log.debug "IPC::Event::Disconnection: #{event.fd}"
when IPC::Event::Disconnection
Log.debug "IPC::Event::Disconnection: #{event.fd}"
when IPC::Event::ExtraSocket
Log.debug "IPC::Event::ExtraSocket: #{event.fd}"
when IPC::Event::ExtraSocket
Log.debug "IPC::Event::ExtraSocket: #{event.fd}"
# 1. accept new websocket clients
if server.fd == event.fd
client = server.accept
begin
websocket_client_connection client
Log.info "new client: #{client.fd}"
rescue e
Log.error "Exception: #{e}"
client.close
# 1. accept new websocket clients
if server.fd == event.fd
client = server.accept
begin
websocket_client_connection client
Log.info "new client: #{client.fd}"
rescue e
Log.error "Exception: #{e}"
client.close
end
next
end
next
# 2. active fd != server fd
activefd = event.fd
if activefd <= 0
Log.error "faulty activefd: #{activefd}"
end
websocket_switching_procedure activefd
when IPC::Event::Switch
Log.debug "IPC::Event::Switch: from fd #{event.fd}"
raise "Not implemented."
# IPC::Event::Message has to be the last entry
# because ExtraSocket and Switch inherit from Message class
when IPC::Event::MessageSent
Log.error "IPC::Event::MessageSent: #{event.fd}"
when IPC::Event::MessageReceived
Log.debug "IPC::Event::MessageReceived: #{event.fd}"
raise "Not implemented."
end
# 2. active fd != server fd
activefd = event.fd
if activefd <= 0
Log.error "faulty activefd: #{activefd}"
end
websocket_switching_procedure activefd
when IPC::Event::Switch
Log.debug "IPC::Event::Switch: from fd #{event.fd}"
raise "Not implemented."
# IPC::Event::Message has to be the last entry
# because ExtraSocket and Switch inherit from Message class
when IPC::Event::MessageSent
Log.error "IPC::Event::MessageSent: #{event.fd}"
when IPC::Event::MessageReceived
Log.debug "IPC::Event::MessageReceived: #{event.fd}"
raise "Not implemented."
rescue e
Log.error "IPC loop final catch: #{e}"
end
end