Fix for 1279 by adding call back on socket disconnect.

Added a call back for disconnect so that we wait for the disconnect to occur before we reconnect. 

Previously this was causing the socket variable to be set to null for the second window after it had been instantiated. Causing a cannot call send of null.