diff src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java @ 35:1b81deb0abb3

write a little part reconnection.
author one
date Wed, 12 Sep 2012 13:16:47 +0900
parents 18fad65bc447
children b7d4d0349f99
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java	Tue Sep 04 19:02:04 2012 +0900
+++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java	Wed Sep 12 13:16:47 2012 +0900
@@ -44,6 +44,10 @@
 import java.io.StringWriter;
 import java.util.logging.Logger;
 
+import jp.ac.u_ryukyu.treevnc.MyRfbProto;
+import jp.ac.u_ryukyu.treevnc.client.EchoClient;
+import jp.ac.u_ryukyu.treevnc.client.MyRfbProtoClient;
+
 public class ReceiverTask implements Runnable {
 	private static final byte FRAMEBUFFER_UPDATE = 0;
 	private static final byte SET_COLOR_MAP_ENTRIES = 1;
@@ -62,6 +66,16 @@
 	protected final ProtocolContext context;
 	protected PixelFormat pixelFormat;
 	protected boolean needSendPixelFormat;
+	private MyRfbProto rfb;
+	
+	public ReceiverTask(Reader reader,
+            IRepaintController repaintController, ClipboardController clipboardController,
+            DecodersContainer decoders, ProtocolContext context,
+            MyRfbProto _rfb) {
+		this(reader,repaintController,clipboardController,decoders,context);
+		rfb = _rfb;
+	}
+	
 	
 	public ReceiverTask(Reader reader,
 	                    IRepaintController repaintController, ClipboardController clipboardController,
@@ -107,7 +121,12 @@
 				}
 			} catch (TransportException e) {
 				logger.severe("Close session: " + e.getMessage());
-				if (isRunning) {
+				if(rfb instanceof MyRfbProtoClient) {
+					System.out.println("task stop");
+					EchoClient echo = rfb.getEcho();
+					echo.openport();
+					echo.lostHost();
+				} else if (isRunning) {
 					context.cleanUpSession("Connection closed.");
 				}
 				stopTask();