import java.net.InetSocketAddress;
import java.net.URL;
import java.net.SocketException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
import com.tigervnc.rdr.*;
import com.tigervnc.rfb.*;
setServerName(serverHost);
setStreams(sock.inStream(), sock.outStream());
initialiseProtocol();
+ int delay = viewer.keepAliveTimeout.getValue();
+ if (delay > 0) {
+ ActionListener keepAliveListener = new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ synchronized (writer()) {
+ writer().writeFramebufferUpdateRequest(new Rect(0,0,0,0), true);
+ }
+ }
+ };
+ keepAliveTimer = new Timer(1000*delay, keepAliveListener);
+ keepAliveTimer.start();
+ }
}
public void refreshFramebuffer()
// deleteWindow() is called when the user closes the desktop or menu windows.
void deleteWindow() {
+ if (keepAliveTimer != null)
+ keepAliveTimer.stop();
if (viewport != null)
viewport.dispose();
viewport = null;
}
firstUpdate = false;
+ if (keepAliveTimer != null)
+ keepAliveTimer.restart();
}
// A format change has been scheduled and we are now past the update
}
forceNonincremental = false;
+ if (keepAliveTimer != null)
+ keepAliveTimer.restart();
}
synchronized public void writeClientCutText(String str, int len) {
if (state() != RFBSTATE_NORMAL) return;
writer().writeClientCutText(str,len);
+ if (keepAliveTimer != null)
+ keepAliveTimer.restart();
}
synchronized public void writeKeyEvent(int keysym, boolean down) {
if ((m & Event.META_MASK) != (pressedModifiers & Event.META_MASK))
writeKeyEvent(Keysyms.Meta_L, (m & Event.META_MASK) != 0);
pressedModifiers = m;
+ if (keepAliveTimer != null)
+ keepAliveTimer.restart();
}
ImageIcon logo = new ImageIcon(cl.getResource("com/tigervnc/vncviewer/tigervnc.png"));
public static UserPasswdGetter upg;
public UserMsgBox msg;
+ Timer keepAliveTimer;
// shuttingDown is set by the GUI thread and only ever tested by the RFB
// thread after the window has been destroyed.
"Use specified compression level "+
"0 = Low, 6 = High",
1);
+ IntParameter keepAliveTimeout
+ = new IntParameter("KeepAliveTimeout",
+ "Send dummy framebuffer update requests if no "+
+ "network activity has occurred for more than "+
+ "the specified number of seconds. This is to "+
+ "prevent VPNs or other applications from "+
+ "disconnecting due to inactivity. A value of "+
+ "0 disables this feature.", 0);
BoolParameter noJpeg
= new BoolParameter("NoJPEG",
"Disable lossy JPEG compression in Tight encoding.", false);