From 00ffa50054221d256c312cdf7ffa0169dd7020d6 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Fri, 4 Nov 2011 11:46:56 +0100 Subject: [PATCH] added events on_launched and on_stopped to ease integration with launching application --- library/http_handler.e | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/library/http_handler.e b/library/http_handler.e index bfc9cb1c..b395d853 100644 --- a/library/http_handler.e +++ b/library/http_handler.e @@ -49,13 +49,12 @@ feature -- Inherited Features end else l_http_port := l_http_socket.port - port := l_http_port from l_http_socket.listen (main_server_configuration.max_tcp_clients) if is_verbose then print ("%NHTTP Connection Server ready on port " + l_http_port.out +" : http://localhost:" + l_http_port.out + "/%N") end - launched := True + on_launched (l_http_port) until is_stop_requested loop @@ -78,7 +77,9 @@ feature -- Inherited Features socket_is_closed: l_http_socket.is_closed end end - launched := False + if launched then + on_stopped + end if is_verbose then print ("HTTP Connection Server ends.") end @@ -91,11 +92,36 @@ feature -- Inherited Features socket_is_closed: ll_http_socket.is_closed end end - launched := False + if launched then + on_stopped + end is_stop_requested := True retry end +feature -- Event + + on_launched (a_port: INTEGER) + -- Server launched using port `a_port' + require + not_launched: not launched + do + launched := False + port := a_port + ensure + launched: launched + end + + on_stopped + -- Server stopped + require + launched: launched + do + launched := False + ensure + stopped: not launched + end + feature -- Access is_verbose: BOOLEAN