Mercurial > hg > Applications > TreeVNC
changeset 326:1d4d5055a288
add error message, add assure stream close.
author | oc |
---|---|
date | Sun, 01 Feb 2015 15:30:17 +0900 |
parents | cc9d33208f34 |
children | 293c35aa902b |
files | src/main/java/com/glavsoft/rfb/encoding/decoder/DecodersContainer.java src/main/java/com/glavsoft/rfb/encoding/decoder/ZlibDecoder.java src/main/java/com/glavsoft/rfb/protocol/Protocol.java src/main/java/com/glavsoft/rfb/protocol/SenderTask.java src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncProtocol.java src/main/java/jp/ac/u_ryukyu/treevnc/VncProxyService.java |
diffstat | 7 files changed, 19 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/encoding/decoder/DecodersContainer.java Sun Feb 01 06:44:56 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/DecodersContainer.java Sun Feb 01 15:30:17 2015 +0900 @@ -67,15 +67,17 @@ decoders.put(enc, knownDecoders.get(enc).newInstance()); } catch (InstantiationException e) { logError(enc, e); + System.out.println("cannot create decoders instance."); } catch (IllegalAccessException e) { logError(enc, e); + System.out.println("cannot access class or constructor."); } } } } private void logError(EncodingType enc, Exception e) { - Logger.getLogger(this.getClass().getName()).severe("Can not instantiate decoder for encoding type '" + + Logger.getLogger(this.getClass().getName()).severe("Cannot instantiate decoder for encoding type '" + enc.getName() + "' " + e.getMessage()); }
--- a/src/main/java/com/glavsoft/rfb/encoding/decoder/ZlibDecoder.java Sun Feb 01 06:44:56 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/ZlibDecoder.java Sun Feb 01 15:30:17 2015 +0900 @@ -30,13 +30,14 @@ import com.glavsoft.transport.Reader; import java.io.ByteArrayInputStream; +import java.util.logging.Logger; import java.util.zip.DataFormatException; import java.util.zip.Inflater; public class ZlibDecoder extends Decoder { private Inflater decoder; - @Override + @Override public void decode(Reader reader, Renderer renderer, FramebufferUpdateRectangle rect) throws TransportException { int zippedLength = (int) reader.readUInt32();
--- a/src/main/java/com/glavsoft/rfb/protocol/Protocol.java Sun Feb 01 06:44:56 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/Protocol.java Sun Feb 01 15:30:17 2015 +0900 @@ -302,7 +302,7 @@ try { senderThread.join(); } catch (InterruptedException e) { - // nop + System.out.println("any thread has interrupted the current thread"); } senderTask = null; } @@ -316,7 +316,7 @@ try { receiverThread.join(); } catch (InterruptedException e) { - // nop + System.out.println("any thread has interrupted the current thread"); } receiverTask = null; }
--- a/src/main/java/com/glavsoft/rfb/protocol/SenderTask.java Sun Feb 01 06:44:56 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/SenderTask.java Sun Feb 01 15:30:17 2015 +0900 @@ -65,14 +65,16 @@ message.send(writer); } } catch (InterruptedException e) { - // nop + System.out.println("cannot get ClientToServerMessage."); } catch (TransportException e) { + System.out.println("cannot send ClientToServerMessage."); Logger.getLogger(getClass().getName()).severe("Close session: " + e.getMessage()); if (isRunning) { protocolContext.cleanUpSession("Connection closed"); } stopTask(); } catch (Throwable te) { + System.out.println("throwable when ClientToServerMessage send or get"); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); te.printStackTrace(pw);
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java Sun Feb 01 06:44:56 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java Sun Feb 01 15:30:17 2015 +0900 @@ -34,7 +34,7 @@ try { echo.whereToConnect(myHostName,rfb.getAcceptPort()); } catch (IOException e) { - System.out.println("cannot connect to root "+e.getMessage()); + System.out.println("sendWhereToConnect : cannot connect to root "+e.getMessage()); } }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncProtocol.java Sun Feb 01 06:44:56 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncProtocol.java Sun Feb 01 15:30:17 2015 +0900 @@ -75,9 +75,13 @@ public void sendCommandToTheRoot(ByteBuffer buf) throws IOException { char[] charBuf = new char[12]; - is.read(charBuf , 0, 12); // skip root's version header - os.write(buf.array(), 0, buf.limit()); // send our command - streamClose(); + try { + is.read(charBuf, 0, 12); // skip root's version header + os.write(buf.array(), 0, buf.limit()); // send our command + } finally { + if(is != null && os != null) + streamClose(); + } } void streamClose() throws IOException {
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/VncProxyService.java Sun Feb 01 06:44:56 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/VncProxyService.java Sun Feb 01 15:30:17 2015 +0900 @@ -74,6 +74,7 @@ @Override public void rfbSessionStopped(final String reason) { + System.out.println(reason); } @Override