Esempio n. 1
0
  private void attachImpl(DebugEventListener listener)
      throws IOException, UnsupportedVersionException, MethodIsBlockingException {
    connectionState = ConnectionState.CONNECTING;

    NetListener netListener =
        new NetListener() {
          public void connectionClosed() {}

          public void eosReceived() {
            debugSession.getV8CommandProcessor().processEos();
            onDebuggerDetachedImpl(null);
          }

          public void messageReceived(Message message) {
            JSONObject json;
            try {
              json = JsonUtil.jsonObjectFromJson(message.getContent());
            } catch (ParseException e) {
              LOGGER.log(Level.SEVERE, "Invalid JSON received: {0}", message.getContent());
              return;
            }
            debugSession.getV8CommandProcessor().processIncomingJson(json);
          }
        };
    connection.setNetListener(netListener);

    connection.start();

    connectionState = ConnectionState.EXPECTING_HANDSHAKE;

    Handshaker.StandaloneV8.RemoteInfo remoteInfo;
    try {
      remoteInfo =
          handshaker.getRemoteInfo().get(WAIT_FOR_HANDSHAKE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
      throw new RuntimeException(e);
    } catch (ExecutionException e) {
      throw newIOException("Failed to get version", e);
    } catch (TimeoutException e) {
      throw newIOException("Timed out waiting for handshake", e);
    }

    String versionString = remoteInfo.getProtocolVersion();
    // TODO(peter.rybin): check version here
    if (versionString == null) {
      throw new UnsupportedVersionException(null, null);
    }

    StandaloneVmImpl.this.savedRemoteInfo = remoteInfo;

    StandaloneVmImpl.this.debugEventListener = listener;

    debugSession.startCommunication();

    connectionState = ConnectionState.CONNECTED;
  }
Esempio n. 2
0
 /** @return version of V8 implementation, format is unspecified; not null */
 public String getVmVersion() {
   return savedRemoteInfo.getV8VmVersion();
 }
Esempio n. 3
0
 /** @return name of embedding application as it wished to name itself; might be null */
 public String getEmbedderName() {
   return savedRemoteInfo.getEmbeddingHostName();
 }