@ Override synchronized public boolean connect ( InetSocketAddress addr ) { long now = System . currentTimeMillis ( ) ; if ( isStarted ) { return true ; } isStarted = true ; String host = addr . getHostName ( ) ; int port = addr . getPort ( ) ; serverURI = URI . create ( "ws://" + host + ":" + port + "/ws/service/" ) ; if ( LOGGER . isTraceEnabled ( ) ) { LOGGER . trace ( "WebSocket connect to timeOut=" + connectTimeOut + " - " + serverURI . toString ( ) ) ; } client = new WebSocketClient ( ) ; doConnect ( ) ; synchronized ( sessionLock ) { long to = connectTimeOut - ( System . currentTimeMillis ( ) - now ) ; while ( ! connected && to > 0 ) { try { sessionLock . wait ( to ) ; } catch ( InterruptedException e ) { // do nothing. } to = connectTimeOut - ( System . currentTimeMillis ( ) - now ) ; } } return true ; }
Connect to the remote socket .