example launch the vnc by tightvnc java library
2013-05-20
After a few hours hack into the tightvnc code, i can display the vnc onto a JPanel, i will replace the buggy novnc with my own vnc proxy server, so user don’t need to setup the novnc for openstack but able to remote to every instance using openstack.
Viewer viewer = new Viewer(); try { Socket workingSocket = new Socket("210.5.164.14", 9401); workingSocket.setTcpNoDelay(true); // disable Nagle algorithm Reader reader = new Reader(workingSocket.getInputStream()); Writer writer = new Writer(workingSocket.getOutputStream()); ProtocolSettings rfbSettings = ProtocolSettings.getDefaultSettings(); Protocol workingProtocol = new Protocol(reader, writer, new PeterIPasswordRetriever(), rfbSettings); UiSettings uiSettings = new UiSettings(); uiSettings.setMouseCursorShape(LocalMouseCursorShape.DOT); uiSettings.setFullScreen(false); uiSettings.setScalePercent(100); boolean hasJsch = true; boolean allowInteractive = false;//allowAppletInteractiveConnections || ! isApplet; ConnectionPresenter connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive); ConnectionParams connectionParams = new ConnectionParams(); connectionPresenter.addModel("ConnectionParamsModel", connectionParams); final ConnectionView connectionView = new ConnectionView(TightVNC.this, // appWindowListener connectionPresenter, hasJsch); SwingViewerWindow viewerWindow = createViewerWindow(workingProtocol, rfbSettings, uiSettings, "p:9401", connectionPresenter); SwingViewerWindowFactory viewerWindowFactory = new SwingViewerWindowFactory(true, false, viewer); connectionPresenter.setConnectionWorkerFactory(new SwingConnectionWorkerFactory(connectionView.getFrame(), "mypassword", connectionPresenter, viewerWindowFactory)); connectionPresenter.startConnection(rfbSettings, uiSettings, 0); } catch (Exception ex) { ex.printStackTrace(); }
PeterIPasswordRetriever.java:
class PeterIPasswordRetriever implements IPasswordRetriever { @Override public String getPassword() { return "mypassword"; } }