public class MuxServer
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private boolean[] |
inputReady |
private java.io.InputStream |
is |
private boolean |
isClient |
private boolean |
isClosed |
private boolean |
isReadLocked |
private boolean |
isWriteLocked |
private java.io.OutputStream |
os |
private java.lang.Object |
READ_LOCK |
private java.lang.Object |
WRITE_LOCK |
Constructor and Description |
---|
MuxServer()
Null argument constructor.
|
MuxServer(java.io.InputStream is,
java.io.OutputStream os,
boolean isClient)
Create a new multiplexor with input and output streams.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the mux
|
(package private) void |
close(int channel) |
(package private) void |
flush(int channel) |
(package private) void |
freeReadLock()
Frees the channel for reading.
|
(package private) void |
freeWriteLock()
Frees the channel for writing.
|
java.io.InputStream |
getInputStream()
Gets the raw input stream.
|
java.io.OutputStream |
getOutputStream()
Gets the raw output stream.
|
(package private) boolean |
getReadLock() |
void |
init(java.io.InputStream is,
java.io.OutputStream os,
boolean isClient)
Initialize the multiplexor with input and output streams.
|
(package private) java.io.InputStream |
readChannel(int channel)
Reads data from a channel.
|
private void |
readData()
Reads data until a channel packet 'C' or error 'E' is received.
|
boolean |
readRequest(MuxInputStream in,
MuxOutputStream out)
Reads a server request.
|
boolean |
startCall(int channel,
MuxInputStream in,
MuxOutputStream out)
Starts a client call.
|
boolean |
startCall(MuxInputStream in,
MuxOutputStream out)
Starts a client call.
|
(package private) java.io.OutputStream |
writeChannel(int channel)
Grabs the channel for writing.
|
(package private) void |
yield(int channel) |
private java.lang.Object READ_LOCK
private java.lang.Object WRITE_LOCK
private java.io.InputStream is
private java.io.OutputStream os
private boolean isClient
private transient boolean isClosed
private boolean[] inputReady
private boolean isReadLocked
private boolean isWriteLocked
public MuxServer()
public MuxServer(java.io.InputStream is, java.io.OutputStream os, boolean isClient)
is
- the underlying input streamos
- the underlying output streamisClient
- true if this is the connection client.public void init(java.io.InputStream is, java.io.OutputStream os, boolean isClient)
is
- the underlying input streamos
- the underlying output streamisClient
- true if this is the connection client.public java.io.InputStream getInputStream()
public java.io.OutputStream getOutputStream()
public boolean startCall(MuxInputStream in, MuxOutputStream out) throws java.io.IOException
java.io.IOException
public boolean startCall(int channel, MuxInputStream in, MuxOutputStream out) throws java.io.IOException
java.io.IOException
public boolean readRequest(MuxInputStream in, MuxOutputStream out) throws java.io.IOException
java.io.IOException
java.io.OutputStream writeChannel(int channel) throws java.io.IOException
channel
- the channeljava.io.IOException
void yield(int channel) throws java.io.IOException
java.io.IOException
void flush(int channel) throws java.io.IOException
java.io.IOException
void close(int channel) throws java.io.IOException
java.io.IOException
void freeWriteLock()
java.io.InputStream readChannel(int channel) throws java.io.IOException
channel
- the channeljava.io.IOException
boolean getReadLock()
void freeReadLock()
private void readData() throws java.io.IOException
java.io.IOException
public void close() throws java.io.IOException
java.io.IOException