public final class Session extends Thread
A Thread
is used to shuttle data back and force between the HTTP client
and the process that was forked. You can check the liveness of this thread to see
if the child process is still alive or not.
Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
Session(int width,
int height,
ProcessWithPty childProcessWithTty) |
Session(int width,
int height,
String terminal,
String... commands)
Creates a terminal session that pumps message between the child process and
Terminal . |
Modifier and Type | Method and Description |
---|---|
static String |
getAjaxTerm()
Name of the terminal ajaxterm.js is implmenting.
|
Process |
getChildProcess() |
long |
getLastAccess()
When was this session accessed by the client the last time?
|
Terminal |
getTerminal() |
long |
getTime()
When was this session allocated?
|
void |
handleUpdate(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse rsp)
Receives the call from the client-side JavaScript.
|
ScreenImage |
handleUpdate(String keys,
boolean color,
int clientTimestamp)
Receives the call from the client-side JavaScript.
|
void |
run() |
void |
write(String k)
Write to the child process.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public Session(int width, int height, String terminal, String... commands) throws IOException
Terminal
.width
- Width of the terminal. For example, 80.height
- Height of the terminal. For example, 25.terminal
- Terminal name set to the TERM environment variable.
For the JavaScript terminal implemented in ajaxterm.js, specify the value taken from getAjaxTerm()
commands
- Command line arguments of the process to launch.
{"/bin/bash","--login"} for example.IOException
public Session(int width, int height, ProcessWithPty childProcessWithTty) throws IOException
width
- Width of the terminal. For example, 80.height
- Height of the terminal. For example, 25.childProcessWithTty
- A child process forked with pty as its stdin/stdout.
Normally this needs to be created with PtyProcessBuilder
.
Make sure to set the correct terminal name in its environment variable.IOException
PtyProcessBuilder
public Terminal getTerminal()
public long getLastAccess()
public long getTime()
public void handleUpdate(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse rsp) throws IOException, InterruptedException
IOException
InterruptedException
public ScreenImage handleUpdate(String keys, boolean color, int clientTimestamp) throws IOException, InterruptedException
IOException
InterruptedException
public void write(String k) throws IOException
IOException
public Process getChildProcess()
public static String getAjaxTerm()
Copyright © 2015. All rights reserved.