code: private synchronized void connectionOpened(String protocol, 
                                                 String extensionsHeader) {
          // ### TODO: Currently, the Gateway is not sending the negotiated
          //           protocol.
          setNegotiatedProtocol(protocol);
          
          // Parse the negotiated extensions and parameters. This can result in 
          // _exception to be setup indicating that there is something wrong
          // while parsing the negotiated extensions and parameters.
          setNegotiatedExtensions(extensionsHeader);
          
          if ((getException() == null) && (_readyState == ReadyState.CONNECTING)) {
              _readyState = ReadyState.OPEN;
          }
          else {
              // The exception can be caused either while parsing the negotiated
              // extensions and parameters or the expiry of the connection timeout.
              // The parsing of negotiated extension can cause an exception if -- 
              // 1) a negotiated extension is not an enabled extension or
              // 2) the type of a negotiated parameter is not String.
              _readyState = ReadyState.CLOSED;
              
              // Inform the Gateway to close the WebSocket.
              _handler.processClose(_channel, 0, null);
          }
  
          // Unblock the connect() call so that it can proceed.
          notifyAll();
      }
docs: --------------------- Private Implementation --------------------------