use of com.oracle.truffle.tools.utils.java_websocket.handshake.ServerHandshake in project graal by oracle.
the class MultiEngineTest method checkSuspendAndResume.
private static void checkSuspendAndResume(String path) throws Exception {
CountDownLatch closed = new CountDownLatch(1);
AtomicBoolean paused = new AtomicBoolean(false);
AtomicReference<Exception> exception = new AtomicReference<>(null);
final String url = "ws://" + InetAddress.getLoopbackAddress().getHostAddress() + ":" + PORT + "/" + path;
WebSocketClient wsc = new WebSocketClient(new URI(url)) {
@Override
public void onOpen(ServerHandshake sh) {
}
@Override
public void onMessage(String message) {
JSONObject msg = new JSONObject(message);
if ("Debugger.paused".equals(msg.opt("method"))) {
paused.set(true);
send("{\"id\":5,\"method\":\"Debugger.resume\"}");
}
}
@Override
public void onClose(int i, String message, boolean bln) {
closed.countDown();
}
@Override
public void onError(Exception excptn) {
excptn.printStackTrace();
exception.set(excptn);
}
};
final boolean connectionSucceeded = wsc.connectBlocking();
assertTrue("Connection has not succeeded: " + url, connectionSucceeded);
for (String message : INITIAL_MESSAGES) {
wsc.send(message);
}
closed.await();
wsc.close();
if (exception.get() != null) {
throw exception.get();
}
}
Aggregations