public class InBandBytestreamSession extends Object implements BytestreamSession
In-band bytestreams are bidirectional and this session encapsulates the streams for both directions.
Note that closing the In-Band Bytestream session will close both streams. If both streams are
closed individually the session will be closed automatically once the second stream is closed.
Use the setCloseBothStreamsEnabled(boolean)
method if both streams should be closed
automatically if one of them is closed.
Modifier | Constructor and Description |
---|---|
protected |
InBandBytestreamSession(XMPPConnection connection,
Open byteStreamRequest,
Jid remoteJID)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the bytestream session.
|
protected void |
closeByLocal(boolean in)
This method is invoked if one of the streams has been closed locally, if an error occurred
locally or if the whole session should be closed.
|
protected void |
closeByPeer(Close closeRequest)
This method is invoked if a request to close the In-Band Bytestream has been received.
|
InputStream |
getInputStream()
Returns the InputStream associated with this session to send data.
|
OutputStream |
getOutputStream()
Returns the OutputStream associated with this session to receive data.
|
int |
getReadTimeout()
Returns the timeout for read operations of the input stream associated with this session.
|
boolean |
isCloseBothStreamsEnabled()
Returns whether both streams should be closed automatically if one of the streams is closed.
|
void |
processIQPacket(Data data)
Process IQ stanza.
|
void |
setCloseBothStreamsEnabled(boolean closeBothStreamsEnabled)
Sets whether both streams should be closed automatically if one of the streams is closed.
|
void |
setReadTimeout(int timeout)
Sets the specified timeout, in milliseconds.
|
protected InBandBytestreamSession(XMPPConnection connection, Open byteStreamRequest, Jid remoteJID)
connection
- the XMPP connectionbyteStreamRequest
- the In-Band Bytestream open request for this sessionremoteJID
- JID of the remote peerpublic InputStream getInputStream()
BytestreamSession
getInputStream
in interface BytestreamSession
public OutputStream getOutputStream()
BytestreamSession
getOutputStream
in interface BytestreamSession
public int getReadTimeout()
BytestreamSession
getReadTimeout
in interface BytestreamSession
public void setReadTimeout(int timeout)
BytestreamSession
setReadTimeout
in interface BytestreamSession
timeout
- the specified timeout, in millisecondspublic boolean isCloseBothStreamsEnabled()
false
.true
if both streams will be closed if one of the streams is closed,
false
if both streams can be closed independently.public void setCloseBothStreamsEnabled(boolean closeBothStreamsEnabled)
false
.closeBothStreamsEnabled
- true
if both streams should be closed if one of
the streams is closed, false
if both streams should be closed
independentlypublic void close() throws IOException
BytestreamSession
Closing the session will also close the input stream and the output stream associated to this session.
close
in interface BytestreamSession
IOException
- if an error occurs while closing the sessionprotected void closeByPeer(Close closeRequest) throws SmackException.NotConnectedException, InterruptedException
closeRequest
- the close request from the remote peerSmackException.NotConnectedException
InterruptedException
protected void closeByLocal(boolean in) throws IOException
in
- do we want to close the Input- or OutputStream?IOException
- if an error occurs while sending the close requestpublic void processIQPacket(Data data) throws SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
data
- SmackException.NotConnectedException
InterruptedException
SmackException.NotLoggedInException