Class HostSession

java.lang.Object
com.iizix.term.HostSession

public class HostSession extends Object
The 3270 or 5250 (or EE) host session.
  • Constructor Details Link icon

  • Method Details Link icon

    • addListener Link icon

      public void addListener(HostSessionListener listener)
      Adds a listener for host session changes.
      Parameters:
      listener - The host session listener.
    • removeListener Link icon

      public void removeListener(HostSessionListener listener)
      Removes a listener for host session changes.
      Parameters:
      listener - The host session listener.
    • getListeners Link icon

      public HostSessionListener[] getListeners()
      Gets the listeners.
    • getProperties Link icon

      public TerminalProps getProperties()
      Gets the terminal properties.
    • getKeyboardRemapper Link icon

      public KeyboardRemapper getKeyboardRemapper()
      Gets the keyboard remapper for this session.
    • getType Link icon

      public TerminalProps.Type getType()
      Gets the terminal type.
    • getStringType Link icon

      public String getStringType()
      Gets the type of session as a String (3270, 5250, EE [when not connected], EE-3270 or EE-5250 [when EE is connected]).
    • getID Link icon

      public String getID()
      Gets the terminal session ID.
    • is3270 Link icon

      public boolean is3270()
      Checks the session type against 3270. If no session type is available, 3270 is assumed.
    • isConnected Link icon

      public boolean isConnected()
      Checks for session currently connected.
    • isDisconnected Link icon

      public boolean isDisconnected()
      Checks if session is disconnected.
    • isConnecting Link icon

      public boolean isConnecting()
      Flag for session is processing a connect request.
    • isReconnecting Link icon

      public boolean isReconnecting()
      Check if the session is current being reconnected (e.g. to avoid logging of host sessions being established, disconnected).
    • isReconnecting Link icon

      public boolean isReconnecting(HostSessionPeer peer)
      Check if the session is current being reconnected (e.g. to avoid logging of host sessions being established, disconnected).
    • getLastException Link icon

      public Throwable getLastException()
      Gets the last communication exception, reset at connect.
      Returns:
      The exception, or null for none.
    • connect Link icon

      public boolean connect()
      Connects the session.
    • disconnect Link icon

      public boolean disconnect()
      Disconnects the session.
    • sendString Link icon

      public boolean sendString(String keys)
      Sends character keystrokes to host.
    • sendString Link icon

      public boolean sendString(String keys, boolean allowTypeAhead)
      Sends character keystrokes to host.
    • sendCharacterString Link icon

      public boolean sendCharacterString(String keys)
      Sends character keystrokes to host.
    • sendCharacterString Link icon

      public boolean sendCharacterString(String keys, boolean allowTypeAhead)
      Sends character keystrokes to host without allowing type-ahead.
    • isTypeAheadEnabled Link icon

      public boolean isTypeAheadEnabled()
      Checks if type-ahead is enabled for this session.
    • sendKey Link icon

      public boolean sendKey(int key)
      Sends keystrokes to host without allowing type-ahead.
      See Also:
    • sendKey Link icon

      public boolean sendKey(int key, boolean allowTypeAhead)
      Sends keystrokes to host.
      See Also:
    • printSession Link icon

      public boolean printSession(HostSessionPeer peer)
      Print terminal session.
      Returns:
      false if this is not a Java client session, true otherwise.
    • doesHostNeedFieldExit Link icon

      public boolean doesHostNeedFieldExit(int x, int y, int offset, int length, String string)
      For 5250 only: checks if a field has the attributes that requires this particular string to enter the data followed by a "Field Exit" or "Field Minus" key. For 3270 it's always false.
    • setHostString Link icon

      public boolean setHostString(int x, int y, int offset, int length, String string)
      Sets a string to a host field.
    • setHostStringAsKeys Link icon

      public boolean setHostStringAsKeys(int x, int y, int offset, int length, String string)
      Sets a string to a host field just as if the user typed the characters. The host field is first cleared with (3270) Clear EOF or (5250) Field Exit or Field Minus (for negative numbers in a numeric field). The string is then entered as a set of keystrokes, followed by a potential Field Exit or Field Minus (for negative numbers in a numeric field), but only for 5250.
    • setCursor Link icon

      public boolean setCursor(int x, int y)
      Sets the host cursor position.
    • getCursor Link icon

      public Position getCursor()
      Gets the current host cursor position.
    • getCharactersAndAttributes Link icon

      public void getCharactersAndAttributes(char[] chars, int[] attrbs, int beginPos, int endPos)
      Gets the characters and attributes between two positions, including the end position.
    • getCharactersAndAttributes Link icon

      public void getCharactersAndAttributes(char[] chars, int[] attrbs, int beginPos, int endPos, char fieldOrNullChar)
      Gets the characters and attributes between two positions, including the end position. The character "fieldOrNullChar" is the character that will be used instead of field attributes and null characters.
    • onScreenChange Link icon

      public void onScreenChange(HostSessionPeer peer, int beginPos, int endPos)
      Notifies the session of a screen change.
    • onScreenChange Link icon

      public void onScreenChange(RemoteHostSessionListener listener, HostSessionPeer peer, int beginPos, int endPos)
      Method to update the screen of a RemoteHostScreenListener.
      Parameters:
      listener - The listener to update, or null for all.
      peer - The peer.
    • getScreenCompression Link icon

      public ScreenCompression getScreenCompression()
      Gets the screen compressor.
    • onFieldChange Link icon

      public void onFieldChange(HostSessionPeer peer)
      Notifies the session that fields have changed.
    • onScreenSizeChange Link icon

      public void onScreenSizeChange(HostSessionPeer peer, int cx, int cy)
      Notifies the session that the screen size has changed.
    • onCursorPositionChange Link icon

      public void onCursorPositionChange(HostSessionPeer peer, int x, int y)
      Notifies the session that the cursor position has changed.
    • onConnectChange Link icon

      public void onConnectChange(HostSessionPeer peer, boolean connected)
      Notifies the session of a connect state change.
    • onStateChange Link icon

      public void onStateChange(HostSessionPeer peer)
      Notifies the session of a state change (such as insert mode, lock state, error state).
    • getScreen Link icon

      public HostScreen getScreen()
      Gets the current host screen instance.
    • getHostScreenSize Link icon

      public Size getHostScreenSize()
      Gets the host screen size.
    • getHostScreenLength Link icon

      public int getHostScreenLength()
      Gets the current screen length (width * height).
    • getSessionState Link icon

      public int getSessionState()
      Gets the host session state.
      Returns:
      A combination of STATE_* flags is returned.
    • isLocked Link icon

      public boolean isLocked()
      Checks if the host session is locked.
    • isKeyboardInputAllowed Link icon

      public boolean isKeyboardInputAllowed()
      Checks if the host session is locked for keyboard input. Keyboard input is allowed for 5250 sessions when in System Request mode or the Attention key is sent.
    • hasError Link icon

      public boolean hasError()
      Checks if there is an error state.
    • inInsertMode Link icon

      public boolean inInsertMode()
      Checks if the keyboard is in insert mode or not.
    • refreshHostFields Link icon

      public final void refreshHostFields()
      Refreshes the host fields of the current session. The host session will add all available host fields sorted left to right, top to bottom.
    • getSessionInfo Link icon

      public SessionInfo getSessionInfo()
      Gets the current SessionInfo.
    • soundAlarm Link icon

      public void soundAlarm(HostSessionPeer peer)
      Sound alarm on the client.
    • onSessionFailure Link icon

      public void onSessionFailure(HostSessionPeer peer, Throwable exception)
      Called when a session has had a failure.
    • getLastError Link icon

      public String getLastError(boolean doClear)
      Gets the last error message of the session.
      Returns:
      null if the session doesn't support it (3270 doesn't).
    • setLastError Link icon

      public void setLastError(String errMsg)
      Sets the last error message of the session.
    • getDeviceName Link icon

      public String getDeviceName()
      Gets the device name of the session.
      Returns:
      null if no device name exists.
    • onHostPrintPage Link icon

      public void onHostPrintPage(HostSessionPeer peer)
      Called when a host printer needs printing of a new page.
    • getPeer Link icon

      public HostSessionPeer getPeer()
      Gets the peer.

      Note that manipulation of the peer directly needs synchronization of that object.

    • clearTypeAhead Link icon

      public void clearTypeAhead()
      Clears the type-ahead buffer.
    • setInsertMode Link icon

      public boolean setInsertMode(boolean on)
      Sets the insert mode.
      Returns:
      true for success, false for failure.
    • replaceOwner Link icon

      public void replaceOwner(HostSessionOwner owner)
      Replaces the host session owner for this session.
    • isProcessingDataStream Link icon

      public boolean isProcessingDataStream()
      Checks if the session is currently processing data stream commands to update the screen/cursor, state, etc.
    • onHostDataStreamProcessing Link icon

      public void onHostDataStreamProcessing(HostSessionPeer peer, boolean isEntering)
      Called when entering or exiting data stream processing.
    • getAllowedCharacters Link icon

      public String getAllowedCharacters()
      Gets the string of characters that can be input by the user using the configured host code page for this session.

      If the return string is empty, for the EE package for example, all characters are "inputable".

    • isFieldFormatted Link icon

      public boolean isFieldFormatted()
      Checks if this host screen is field formatted. This method is not like the one in HostScreen, this one checks directly to see if any fields are present.
    • getWorker Link icon

      public Worker getWorker() throws IOException
      Gets the worker instance of the session.
      Throws:
      IOException
    • performCopy Link icon

      public String performCopy(int oper, int x, int y, int cx, int cy)
      Performs a copy operation to a clip board string for terminal screen.
      Parameters:
      oper - 0=divide by field, 1=by word, 2=data only.
      x - The x position.
      y - The y position.
      cx - The width.
      cy - The height.
      Returns:
      null if the operation could not be completed due to invalid host session or parameters, otherwise the copied string.
    • performClear Link icon

      public boolean performClear(int x, int y, int cx, int cy)
      Performs a clear operation in the terminal screen.
      Returns:
      false if the operation could not be completed due to invalid host session or parameters, true otherwise.
    • performPaste Link icon

      public String performPaste(String data, boolean byField, boolean doPasteTextWrapping)
      Performs a paste operation.
      Parameters:
      byField - Flag used only when tabs are in the string.
      doPasteTextWrapping - Flag to paste too long text wrapping.
      Returns:
      The rest of the clip board data that couldn't be pasted (in order to perform another Continue paste operation), or null for failure.
    • performSuspend Link icon

      public boolean performSuspend()
      Suspends or resumes the session.
      Returns:
      true for success, false for failure.
    • isSuspended Link icon

      public boolean isSuspended()
      Checks if session is suspended.
    • performResume Link icon

      public boolean performResume()
      Resumes the session.
      Returns:
      true for success, false for failure.
    • canConnect Link icon

      public boolean canConnect()
      Checks for connect operation possible, used typically for GUI operations.
    • canSuspend Link icon

      public boolean canSuspend()
      Checks for suspend operation possible, used typically for GUI operations.
    • canResume Link icon

      public boolean canResume()
      Checks for resume operation possible, used typically for GUI operations.
    • canDisconnect Link icon

      public boolean canDisconnect()
      Checks for disconnect operation possible, used typically for GUI operations.
    • isCaptured Link icon

      public boolean isCaptured()
      Checks if this is a screen capture or a "real" 3270/5250 session.
    • getInfo Link icon

      public String getInfo()
      Gets the info of the Terminal Session. The name is either the file name for a capture session or the terminal properties name. The first character is '0'=live 3270/5250, '1'=capture, '2'=recorded.