Search in sources :

Example 1 with HasLifecycle

use of io.deephaven.web.client.api.lifecycle.HasLifecycle in project deephaven-core by deephaven.

the class WorkerConnection method onClose.

// @Override
public void onClose(int code, String message) {
    // notify all active tables, tablemaps, and figures that the connection is closed
    tableMaps.values().forEach(tableMap -> {
        try {
            tableMap.fireEvent(TableMap.EVENT_DISCONNECT);
            tableMap.suppressEvents();
        } catch (Exception e) {
            JsLog.warn("Error in firing TableMap.EVENT_DISCONNECT event", e);
        }
    });
    figures.forEach((p0, p1, p2) -> {
        try {
            p0.fireEvent(JsFigure.EVENT_DISCONNECT);
            p0.suppressEvents();
        } catch (Exception e) {
            JsLog.warn("Error in firing Figure.EVENT_DISCONNECT event", e);
        }
        return null;
    });
    info.disconnected();
    for (ClientTableState cts : cache.getAllStates()) {
        cts.forActiveLifecycles(HasLifecycle::disconnected);
    }
    if (state == State.Disconnected) {
        // deliberately closed, don't try to reopen at this time
        JsLog.debug("WorkerConnection.onClose Disconnected, not trying to reopen");
        return;
    }
    // try again
    JsLog.debug("WorkerConnection.onClose, trying to reconnect");
    state = State.Reconnecting;
    newSessionReconnect.failed();
    // fail outstanding promises, if any
    onOpen.forEach(c -> c.onFailure("Connection to server closed (" + code + "): " + message));
    onOpen.clear();
}
Also used : ClientTableState(io.deephaven.web.client.state.ClientTableState) HasLifecycle(io.deephaven.web.client.api.lifecycle.HasLifecycle)

Aggregations

HasLifecycle (io.deephaven.web.client.api.lifecycle.HasLifecycle)1 ClientTableState (io.deephaven.web.client.state.ClientTableState)1