コード例 #1
0
 @Test
 public void testDisconnect() throws InterruptedException {
   TerminalConnection connection =
       terminalConnectionFactory.getConnection(new SimpleConnectionProperties());
   while (true) {
     TerminalSendAction action = new SimpleTerminalSendAction("[enter]");
     connection.doAction(action);
     System.out.println(connection.getSnapshot());
     Thread.sleep(5000);
   }
 }
コード例 #2
0
 public void doAction(TerminalSendAction terminalSendAction) {
   lazyConnect();
   terminalSnapshot = null;
   handleRightAdjust(terminalSendAction);
   terminalConnection.doAction(terminalSendAction);
   handleSleep(terminalSendAction);
 }
コード例 #3
0
  private int waitForNonEmptySnapshot() {
    int timer = 0;
    do {
      if (terminalSnapshot == null) {
        terminalSnapshot = terminalConnection.fetchSnapshot();
      }

      if (terminalSnapshot.getFields().size() == 0) {
        try {
          Thread.sleep(waitBetweenEmptyScreens);
          timer += waitBetweenEmptyScreens;
        } catch (InterruptedException e) {
          // do nothing
        }
        terminalSnapshot = null;
      }

    } while (isConnected() && terminalSnapshot == null && timer < maxWaitOnEmptyScreen);
    return timer;
  }
コード例 #4
0
  public TerminalSnapshot getSnapshot() {
    lazyConnect();

    // clear the snapshot sequence is different from the session, clear it so it will re-build
    if (terminalSnapshot != null
        && terminalSnapshot.getSequence() != null
        && !terminalConnection.getSequence().equals(terminalSnapshot.getSequence())) {
      terminalSnapshot = null;
    }

    waitForNonEmptySnapshot();

    if (!isConnected()) {
      disconnect();
      throw (new OpenLegacyRuntimeException("Session is not connected"));
    }

    if (terminalSnapshot == null) {
      throw (new OpenLegacyProviderException(
          MessageFormat.format(
              "Current screen is empty for session after waiting for {0}", maxWaitOnEmptyScreen)));
    }
    return terminalSnapshot;
  }
コード例 #5
0
 public boolean isRightToLeftState() {
   return terminalConnection.isRightToLeftState();
 }
コード例 #6
0
 public void flip() {
   terminalConnection.flip();
 }
コード例 #7
0
 public Integer getSequence() {
   if (!isConnected()) {
     return 0;
   }
   return terminalConnection.getSequence();
 }
コード例 #8
0
 public boolean isConnected() {
   return terminalConnection != null && terminalConnection.isConnected();
 }
コード例 #9
0
 public Object getDelegate() {
   lazyConnect();
   return terminalConnection.getDelegate();
 }