Search in sources :

Example 1 with NGClient

use of com.servoy.j2db.server.ngclient.NGClient in project servoy-client by Servoy.

the class ServoyDebugger method getFrame.

/**
 * @see org.eclipse.dltk.rhino.dbgp.DBGPDebugger#getFrame(org.mozilla.javascript.Context, org.mozilla.javascript.debug.DebuggableScript)
 */
@Override
public DebugFrame getFrame(Context cx, DebuggableScript fnOrScript) {
    final IServiceProvider client = J2DBGlobals.getServiceProvider();
    if (profilelisteners.size() > 0) {
        ProfileInfo info = profileInfo.get();
        return new ServoyDebugFrame(cx, fnOrScript, this, info != null ? info.peek() : null);
    }
    return new DBGPDebugFrame(cx, fnOrScript, this) {

        @Override
        public Object eval(String value) {
            if (client != null && J2DBGlobals.getServiceProvider() == null) {
                J2DBGlobals.setServiceProvider(client);
            }
            boolean reset = false;
            try {
                if (client instanceof NGClient && !CurrentWindow.exists()) {
                    // make sure that for an NGClient the current window is set.
                    CurrentWindow.set(new NGClientWebsocketSessionWindows(((NGClient) client).getWebsocketSession()));
                    reset = true;
                }
                return super.eval(value);
            } finally {
                if (reset)
                    CurrentWindow.set(null);
            }
        }
    };
}
Also used : IServiceProvider(com.servoy.j2db.IServiceProvider) NGClientWebsocketSessionWindows(com.servoy.j2db.server.ngclient.eventthread.NGClientWebsocketSessionWindows) NGClient(com.servoy.j2db.server.ngclient.NGClient) DBGPDebugFrame(org.eclipse.dltk.rhino.dbgp.DBGPDebugFrame)

Example 2 with NGClient

use of com.servoy.j2db.server.ngclient.NGClient in project servoy-client by Servoy.

the class NGClientEndpoint method handleException.

@Override
protected void handleException(final Exception e, final IWebsocketSession session) {
    if (e instanceof ApplicationException) {
        final ApplicationException ae = (ApplicationException) e;
        // if the current window has no endpoint then quickly set it to this instance.
        if (CurrentWindow.exists() && !CurrentWindow.get().hasEndpoint())
            CurrentWindow.get().setEndpoint(this);
        CurrentWindow.runForWindow(new NGClientWebsocketSessionWindows((INGClientWebsocketSession) session), new Runnable() {

            @Override
            public void run() {
                if (ae.getErrorCode() == ServoyException.NO_LICENSE) {
                    session.getClientService("$sessionService").executeAsyncServiceCall("setNoLicense", new Object[] { getLicenseAndMaintenanceDetail() });
                } else if (ae.getErrorCode() == ServoyException.MAINTENANCE_MODE) {
                    session.getClientService("$sessionService").executeAsyncServiceCall("setMaintenanceMode", new Object[] { getLicenseAndMaintenanceDetail() });
                }
            }
        });
    }
    try {
        ((NGClient) ((INGClientWebsocketSession) session).getClient()).shutDown(true);
    } catch (Exception e1) {
        Debug.error("Error calling shutdown on client that had an exception when starting up: " + e.getMessage(), e1);
    }
}
Also used : ApplicationException(com.servoy.j2db.ApplicationException) NGClientWebsocketSessionWindows(com.servoy.j2db.server.ngclient.eventthread.NGClientWebsocketSessionWindows) INGClientWebsocketSession(com.servoy.j2db.server.ngclient.INGClientWebsocketSession) NGClient(com.servoy.j2db.server.ngclient.NGClient) JSONObject(org.json.JSONObject) ServoyException(com.servoy.j2db.util.ServoyException) ApplicationException(com.servoy.j2db.ApplicationException) IOException(java.io.IOException)

Aggregations

NGClient (com.servoy.j2db.server.ngclient.NGClient)2 NGClientWebsocketSessionWindows (com.servoy.j2db.server.ngclient.eventthread.NGClientWebsocketSessionWindows)2 ApplicationException (com.servoy.j2db.ApplicationException)1 IServiceProvider (com.servoy.j2db.IServiceProvider)1 INGClientWebsocketSession (com.servoy.j2db.server.ngclient.INGClientWebsocketSession)1 ServoyException (com.servoy.j2db.util.ServoyException)1 IOException (java.io.IOException)1 DBGPDebugFrame (org.eclipse.dltk.rhino.dbgp.DBGPDebugFrame)1 JSONObject (org.json.JSONObject)1