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