Added a way to call a callback on launched and stopped for Nino connector
This commit is contained in:
@@ -23,6 +23,10 @@ feature {NONE} -- Initialization
|
||||
|
||||
create cfg.make
|
||||
create server.make (cfg)
|
||||
|
||||
-- Callbacks
|
||||
create on_launched_actions
|
||||
create on_stopped_actions
|
||||
end
|
||||
|
||||
make_with_base (a_service: like service; a_base: like base)
|
||||
@@ -69,6 +73,14 @@ feature -- Status report
|
||||
-- Listening port.
|
||||
--| 0: not launched
|
||||
|
||||
feature -- Callbacks
|
||||
|
||||
on_launched_actions: ACTION_SEQUENCE [TUPLE [WGI_CONNECTOR]]
|
||||
-- Actions triggered when launched
|
||||
|
||||
on_stopped_actions: ACTION_SEQUENCE [TUPLE [WGI_CONNECTOR]]
|
||||
-- Actions triggered when stopped
|
||||
|
||||
feature -- Element change
|
||||
|
||||
on_launched (a_port: INTEGER)
|
||||
@@ -76,11 +88,13 @@ feature -- Element change
|
||||
do
|
||||
launched := True
|
||||
port := a_port
|
||||
on_launched_actions.call ([Current])
|
||||
end
|
||||
|
||||
on_stopped
|
||||
-- Server stopped
|
||||
do
|
||||
on_stopped_actions.call ([Current])
|
||||
launched := False
|
||||
port := 0
|
||||
end
|
||||
|
||||
@@ -34,7 +34,12 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
local
|
||||
conn: like connector
|
||||
do
|
||||
create on_launched_actions
|
||||
create on_stopped_actions
|
||||
|
||||
port_number := 80 --| Default, but quite often, this port is already used ...
|
||||
base_url := ""
|
||||
|
||||
@@ -64,14 +69,15 @@ feature {NONE} -- Initialization
|
||||
verbose := l_verbose_str.as_lower.same_string ("true")
|
||||
end
|
||||
end
|
||||
create connector.make (Current)
|
||||
if attached connector as conn then
|
||||
conn.set_base (base_url)
|
||||
if single_threaded then
|
||||
conn.configuration.set_force_single_threaded (True)
|
||||
end
|
||||
conn.configuration.set_is_verbose (verbose)
|
||||
create conn.make (Current)
|
||||
conn.on_launched_actions.extend (agent on_launched)
|
||||
conn.on_stopped_actions.extend (agent on_stopped)
|
||||
connector := conn
|
||||
conn.set_base (base_url)
|
||||
if single_threaded then
|
||||
conn.configuration.set_force_single_threaded (True)
|
||||
end
|
||||
conn.configuration.set_is_verbose (verbose)
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
@@ -104,8 +110,26 @@ feature -- Execution
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Callback
|
||||
|
||||
on_launched_actions: ACTION_SEQUENCE [TUPLE [WGI_CONNECTOR]]
|
||||
-- Actions triggered when launched
|
||||
|
||||
on_stopped_actions: ACTION_SEQUENCE [TUPLE [WGI_CONNECTOR]]
|
||||
-- Actions triggered when stopped
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
on_launched (conn: WGI_CONNECTOR)
|
||||
do
|
||||
on_launched_actions.call ([conn])
|
||||
end
|
||||
|
||||
on_stopped (conn: WGI_CONNECTOR)
|
||||
do
|
||||
on_stopped_actions.call ([conn])
|
||||
end
|
||||
|
||||
port_number: INTEGER
|
||||
|
||||
server_name: detachable READABLE_STRING_8
|
||||
@@ -123,11 +147,11 @@ feature -- Status report
|
||||
|
||||
launchable: BOOLEAN
|
||||
do
|
||||
Result := Precursor and port_number > 0
|
||||
Result := Precursor and port_number >= 0
|
||||
end
|
||||
|
||||
;note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
Reference in New Issue
Block a user