changeset 392:7ac1a0b02f44

add test buffer changed when input stream runs dry, similar to async test
author Carl Byington <carl@five-ten-sg.com>
date Tue, 16 Sep 2014 16:22:41 -0700
parents bcbd579253a1
children 63780d4fa8c3
files src/org/tn5250j/framework/tn5250/DataStreamProducer.java src/org/tn5250j/framework/tn5250/tnvt.java
diffstat 2 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/tn5250j/framework/tn5250/DataStreamProducer.java	Tue Sep 16 11:12:45 2014 -0700
+++ b/src/org/tn5250j/framework/tn5250/DataStreamProducer.java	Tue Sep 16 16:22:41 2014 -0700
@@ -146,6 +146,12 @@
         int i = 0;
 
         while (!done) {
+            try {
+                if (bin.available() == 0) dsq.put(new Integer(0));  // trigger buffer.testChanged()
+            }
+            catch (Exception ex) {
+                Log.w(TAG, "readIncoming error " + ex.getMessage());
+            }
             i = bin.read();
 
             // WVL - LDC : 16/07/2003 : TR.000345
@@ -218,6 +224,12 @@
 
         if (negotiate) {
             // get the negotiation option
+            try {
+                if (bin.available() == 0) dsq.put(new Integer(0));  // trigger buffer.testChanged()
+            }
+            catch (Exception ex) {
+                Log.w(TAG, "readIncoming error " + ex.getMessage());
+            }
             baosin.write(bin.read());
             vt.negotiate(rBytes);
             return null;
--- a/src/org/tn5250j/framework/tn5250/tnvt.java	Tue Sep 16 11:12:45 2014 -0700
+++ b/src/org/tn5250j/framework/tn5250/tnvt.java	Tue Sep 16 16:22:41 2014 -0700
@@ -832,12 +832,11 @@
 
     private final void setInvited() {
         Log.d(TAG, "invited");
-
         if (!screen52.isStatusErrorCode())
             screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_NOTINHIBITED,
                                                 ScreenOIA.OIA_LEVEL_INPUT_INHIBITED);
-
         invited = true;
+        buffer.testChanged();
     }
 
     // WVL - LDC : 05/08/2005 : TFX.006253 - Support STRPCCMD
@@ -986,6 +985,12 @@
         while (keepTrucking) {
             try {
                 Object e = dsq.take();
+
+                if ((e instanceof Integer) && ((Integer)e == 0)) {
+                    buffer.testChanged();
+                    continue;
+                };
+
                 bk.initialize((byte[])e);
             }
             catch (InterruptedException ie) {
@@ -996,7 +1001,6 @@
 
             invited = false;
             screen52.setCursorActive(false);
-
             if (bk == null) continue;
 
             switch (bk.getOpCode()) {
@@ -1105,7 +1109,6 @@
             if (pendingUnlock && !screen52.isStatusErrorCode()) {
                 screen52.getOIA().setKeyBoardLocked(false);
                 pendingUnlock = false;
-                buffer.testChanged();
             }
 
             if (cursorOn && !screen52.getOIA().isKeyBoardLocked()) {