Description
3. have the method start return a subscription that can be used to cancel (i.e, unsubscribe) the http listener, the server loop and any responses that are in progress (hint: use one of the Subscription companion methods)
Instantiating the Server
Finally, you can instantiate the server in the file Main.scala. The main method first creates a server myServer on port 8191 and starts listening on a relative path /test, as implemented. It then creates a userInterrupted future that is completed when the user presses
ENTER, and is continued with a message “You entered… “. Complete the remaning part of the main method which are described below:
1. Create a timeOut future that is completed after 20 seconds, continued with a message “Server timeout!”
2. Create a terminationRequested future that is completed once any of the two futures userInterrupted or timeOut completes.
3. Once the terminationRequested completes, print its message, unsubscribe from myServer and print “Bye!” Hint: where possible, use the previously defined Future factory methods and combinators.
Open your browser and type http://localhost:8191/test into the address bar. Congratulations your server is fully functional!




Reviews
There are no reviews yet.