Final catch for the IPC loop.
This commit is contained in:
parent
6a5496a393
commit
185a87431c
@ -382,50 +382,54 @@ end
|
|||||||
Context.service.base_timer = Context.timer_delay
|
Context.service.base_timer = Context.timer_delay
|
||||||
|
|
||||||
Context.service.loop do |event|
|
Context.service.loop do |event|
|
||||||
case event
|
begin
|
||||||
when IPC::Event::Timer
|
case event
|
||||||
Log.info "IPC::Event::Timer"
|
when IPC::Event::Timer
|
||||||
sending_ping_messages
|
Log.info "IPC::Event::Timer"
|
||||||
when IPC::Event::Connection
|
sending_ping_messages
|
||||||
Log.debug "IPC::Event::Connection: #{event.fd}"
|
when IPC::Event::Connection
|
||||||
|
Log.debug "IPC::Event::Connection: #{event.fd}"
|
||||||
|
|
||||||
when IPC::Event::Disconnection
|
when IPC::Event::Disconnection
|
||||||
Log.debug "IPC::Event::Disconnection: #{event.fd}"
|
Log.debug "IPC::Event::Disconnection: #{event.fd}"
|
||||||
|
|
||||||
when IPC::Event::ExtraSocket
|
when IPC::Event::ExtraSocket
|
||||||
Log.debug "IPC::Event::ExtraSocket: #{event.fd}"
|
Log.debug "IPC::Event::ExtraSocket: #{event.fd}"
|
||||||
|
|
||||||
# 1. accept new websocket clients
|
# 1. accept new websocket clients
|
||||||
if server.fd == event.fd
|
if server.fd == event.fd
|
||||||
client = server.accept
|
client = server.accept
|
||||||
begin
|
begin
|
||||||
websocket_client_connection client
|
websocket_client_connection client
|
||||||
Log.info "new client: #{client.fd}"
|
Log.info "new client: #{client.fd}"
|
||||||
rescue e
|
rescue e
|
||||||
Log.error "Exception: #{e}"
|
Log.error "Exception: #{e}"
|
||||||
client.close
|
client.close
|
||||||
|
end
|
||||||
|
next
|
||||||
end
|
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
|
end
|
||||||
|
rescue e
|
||||||
# 2. active fd != server fd
|
Log.error "IPC loop final catch: #{e}"
|
||||||
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
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user