Class HostSession

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

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

  • Method Details

    • addListener

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

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

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

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

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

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

      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

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

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

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

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

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

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

      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

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

      public boolean connect()
      Connects the session.
    • disconnect

      public boolean disconnect()
      Disconnects the session.
    • sendString

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

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

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

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

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

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

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

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

      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

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

      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

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

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

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

      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

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

      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

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

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

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

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

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

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

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

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

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

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

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

      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

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

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

      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

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

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

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

      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

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

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

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

      public HostSessionPeer getPeer()
      Gets the peer.

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

    • clearTypeAhead

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

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

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

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

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

      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

      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

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

      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

      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

      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

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

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

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

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

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

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

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

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

      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.