Silver Challenge: Closed Connection Alert

In the ws-client module, add another function called registerCloseHandler. It should take a callback that is invoked when the close event is triggered on the socket.

In main.js, use registerCloseHandler to alert the user that the connection is closed. Then, test it to make sure it works.

How can you test it? Obviously, you cannot close the browser window. You will need to close the other end of the connection.

For an added bonus, write a function that attempts to reconnect. You can either use a setTimeout or you can prompt the user for confirmation (search the MDN for details).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.189.228