Added fail-safe mechanism for socket connection.
Users do not need to kill the app and run it again if the socket connection fails.
Long-clicking on the play button will pop up a window for socket reconnection.
Refactored the code.