public synchronized void close ( ) { switch ( state ) { case NONE : state = State . DISCONNECTED ; return ; case CONNECTING : // don't wait for an established connection, just close the tcp socket closeSocket ( ) ; return ; case CONNECTED : // This method also shuts down the writer // the socket will be closed once the ack for the close was received sendCloseHandshake ( true ) ; return ; case DISCONNECTING : return ; // no-op; case DISCONNECTED : return ; // No-op } }
Close down the socket . Will trigger the onClose handler if the socket has not been previously closed .