Source:
public void connect(ConsoleProcess consoleProcess, final ConnectCallback callback) { consoleProcess_ = consoleProcess; if (terminalInputHandler_ == null) terminalInputHandler_ = xterm_.addTerminalDataInputHandler(this); addHandlerRegistration(consoleProcess_.addConsoleOutputHandler(this)); switch (consoleProcess_.getChannelMode()) { case ConsoleProcessInfo.CHANNEL_RPC: Debug.devlog("Using RPC"); callback.onConnected(); break; case ConsoleProcessInfo.CHANNEL_WEBSOCKET: String urlSuffix = consoleProcess_.getProcessInfo().getChannelId() + "/terminal/" + consoleProcess_.getProcessInfo().getHandle() + "/"; String url; if (Desktop.isDesktop()) { url = "ws://127.0.0.1:" + urlSuffix; } else { url = GWT.getHostPageBaseURL(); if (url.startsWith("https:")) { url = "wss:" + url.substring(6) + "p/" + urlSuffix; } else if (url.startsWith("http:")) { url = "ws:" + url.substring(5) + "p/" + urlSuffix; } else { callback.onError("Unable to discover websocket protocol"); return; } } Debug.devlog("Connecting to " + url); socket_ = new Websocket(url); socket_.addListener(new WebsocketListenerExt() { @Override public void onClose(CloseEvent event) { Debug.devlog("Disconnected websocket for " + consoleProcess_.getProcessInfo().getHandle()); socket_ = null; } @Override public void onMessage(String msg) { onConsoleOutput(new ConsoleOutputEvent(msg)); } @Override public void onOpen() { callback.onConnected(); } @Override public void onError() { Debug.devlog("Unable to connect websocket, switching back to rpc"); socket_ = null; consoleProcess_.useRpcMode(new ServerRequestCallback<Void>() { @Override public void onResponseReceived(Void response) { callback.onConnected(); } @Override public void onError(ServerError error) { callback.onError("Unable to switch back to Rpc mode"); } }); return; } }); socket_.open(); break; case ConsoleProcessInfo.CHANNEL_PIPE: default: callback.onError("Channel type not implemented"); break; } }

Target:
public void connect(ConsoleProcess consoleProcess, final ConnectCallback callback) { consoleProcess_ = consoleProcess; if (terminalInputHandler_ == null) terminalInputHandler_ = xterm_.addTerminalDataInputHandler(this); addHandlerRegistration(consoleProcess_.addConsoleOutputHandler(this)); switch (consoleProcess_.getChannelMode()) { case ConsoleProcessInfo.CHANNEL_RPC: callback.onConnected(); break; case ConsoleProcessInfo.CHANNEL_WEBSOCKET: String urlSuffix = consoleProcess_.getProcessInfo().getChannelId() + "/terminal/" + consoleProcess_.getProcessInfo().getHandle() + "/"; String url; if (Desktop.isDesktop()) { url = "ws://127.0.0.1:" + urlSuffix; } else { url = GWT.getHostPageBaseURL(); if (url.startsWith("https:")) { url = "wss:" + url.substring(6) + "p/" + urlSuffix; } else if (url.startsWith("http:")) { url = "ws:" + url.substring(5) + "p/" + urlSuffix; } else { callback.onError("Unable to discover websocket protocol"); return; } } socket_ = new Websocket(url); socket_.addListener(new WebsocketListenerExt() { @Override public void onClose(CloseEvent event) { socket_ = null; } @Override public void onMessage(String msg) { onConsoleOutput(new ConsoleOutputEvent(msg)); } @Override public void onOpen() { callback.onConnected(); } @Override public void onError() { socket_ = null; consoleProcess_.useRpcMode(new ServerRequestCallback<Void>() { @Override public void onResponseReceived(Void response) { callback.onConnected(); } @Override public void onError(ServerError error) { callback.onError("Unable to switch back to Rpc mode"); } }); return; } }); socket_.open(); break; case ConsoleProcessInfo.CHANNEL_PIPE: default: callback.onError("Channel type not implemented"); break; } }