Search in sources :

Example 1 with Command

use of com.oracle.truffle.tools.chromeinspector.commands.Command in project graal by oracle.

the class InspectServerSession method onMessage.

public void onMessage(String message) {
    Command cmd;
    try {
        cmd = new Command(message);
    } catch (JSONException ex) {
        PrintWriter err = context.getErr();
        if (err != null) {
            err.println("Illegal message: '" + message + "' " + ex.getLocalizedMessage());
        }
        return;
    }
    processThread.push(cmd);
}
Also used : Command(com.oracle.truffle.tools.chromeinspector.commands.Command) JSONException(org.json.JSONException) PrintWriter(java.io.PrintWriter)

Example 2 with Command

use of com.oracle.truffle.tools.chromeinspector.commands.Command in project graal by oracle.

the class Session method connect.

private Object connect() {
    if (iss != null) {
        throw new InspectorStateException("The inspector session is already connected");
    }
    InspectorExecutionContext execContext = contextSupplier.get();
    iss = InspectServerSession.create(execContext, false, new ConnectionWatcher());
    iss.open(getListeners());
    execContext.setSynchronous(true);
    // Enable the Runtime by default
    iss.sendCommand(new Command("{\"id\":0,\"method\":\"Runtime.enable\"}"));
    return undefinedProvider.get();
}
Also used : Command(com.oracle.truffle.tools.chromeinspector.commands.Command) InspectorExecutionContext(com.oracle.truffle.tools.chromeinspector.InspectorExecutionContext) ConnectionWatcher(com.oracle.truffle.tools.chromeinspector.server.ConnectionWatcher)

Example 3 with Command

use of com.oracle.truffle.tools.chromeinspector.commands.Command in project graal by oracle.

the class Session method post.

private void post(String method, TruffleObject paramsObject, TruffleObject callback) {
    long id = cmdId.getAndIncrement();
    Params params = null;
    if (paramsObject != null) {
        params = new Params(TruffleObject2JSON.fromObject(paramsObject));
    }
    if (callback != null) {
        getListeners().addCallback(id, callback);
    }
    if (iss == null) {
        throw new InspectorStateException("The inspector session is not connected.");
    }
    iss.sendCommand(new Command(id, method, params));
}
Also used : Command(com.oracle.truffle.tools.chromeinspector.commands.Command) Params(com.oracle.truffle.tools.chromeinspector.commands.Params)

Example 4 with Command

use of com.oracle.truffle.tools.chromeinspector.commands.Command in project graal by oracle.

the class InspectServerSession method sendText.

@Override
public void sendText(String message) throws IOException {
    if (processThread == null) {
        throw createClosedException();
    }
    Command cmd;
    try {
        cmd = new Command(message);
    } catch (JSONException ex) {
        PrintWriter err = context.getErr();
        if (err != null) {
            err.println("Illegal message: '" + message + "' " + ex.getLocalizedMessage());
        }
        return;
    }
    CommandProcessThread pt = processThread;
    if (pt != null) {
        pt.push(cmd);
    }
}
Also used : Command(com.oracle.truffle.tools.chromeinspector.commands.Command) JSONException(com.oracle.truffle.tools.utils.json.JSONException) PrintWriter(java.io.PrintWriter)

Aggregations

Command (com.oracle.truffle.tools.chromeinspector.commands.Command)4 PrintWriter (java.io.PrintWriter)2 InspectorExecutionContext (com.oracle.truffle.tools.chromeinspector.InspectorExecutionContext)1 Params (com.oracle.truffle.tools.chromeinspector.commands.Params)1 ConnectionWatcher (com.oracle.truffle.tools.chromeinspector.server.ConnectionWatcher)1 JSONException (com.oracle.truffle.tools.utils.json.JSONException)1 JSONException (org.json.JSONException)1