From c1fcef03cdf37d6bfa3b552985a5b9e6b4f26e69 Mon Sep 17 00:00:00 2001 From: Brian Hinz Date: Sat, 14 Apr 2012 03:20:47 +0000 Subject: [PATCH] Allows java client in listen mode to continue listening and spawning new viewers after the first connection is made. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4891 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- java/com/tigervnc/vncviewer/VncViewer.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/java/com/tigervnc/vncviewer/VncViewer.java b/java/com/tigervnc/vncviewer/VncViewer.java index 850f5f1f..6729521f 100644 --- a/java/com/tigervnc/vncviewer/VncViewer.java +++ b/java/com/tigervnc/vncviewer/VncViewer.java @@ -228,13 +228,17 @@ public class VncViewer extends java.applet.Applet implements Runnable firstApplet = true; } - public static void newViewer(VncViewer oldViewer) { + public static void newViewer(VncViewer oldViewer, Socket sock) { VncViewer viewer = new VncViewer(); viewer.applet = oldViewer.applet; viewer.firstApplet = false; + viewer.sock = sock; viewer.start(); } + public static void newViewer(VncViewer oldViewer) { + newViewer(oldViewer, null); + } public void init() { vlog.debug("init called"); @@ -289,7 +293,6 @@ public class VncViewer extends java.applet.Applet implements Runnable public void run() { CConn cc = null; - Socket sock = null; /* Tunnelling support. */ if (via.getValueStr() != null) { @@ -324,10 +327,9 @@ public class VncViewer extends java.applet.Applet implements Runnable vlog.info("Listening on port "+port); while (true) { - sock = listener.accept(); - if (sock != null) - break; - //listener.close(); + Socket new_sock = listener.accept(); + if (new_sock != null) + newViewer(this, new_sock); } } @@ -456,6 +458,7 @@ public class VncViewer extends java.applet.Applet implements Runnable 8); Thread thread; + Socket sock; boolean applet, firstApplet, stop; Image logo; static int nViewers; -- 2.39.5