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,
String 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) |
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, String remoteJID)
connection - the XMPP connectionbyteStreamRequest - the In-Band Bytestream open request for this sessionremoteJID - JID of the remote peerpublic InputStream getInputStream()
BytestreamSessiongetInputStream in interface BytestreamSessionpublic OutputStream getOutputStream()
BytestreamSessiongetOutputStream in interface BytestreamSessionpublic int getReadTimeout()
BytestreamSessiongetReadTimeout in interface BytestreamSessionpublic void setReadTimeout(int timeout)
BytestreamSessionsetReadTimeout in interface BytestreamSessiontimeout - 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
BytestreamSessionClosing the session will also close the input stream and the output stream associated to this session.
close in interface BytestreamSessionIOException - if an error occurs while closing the sessionprotected void closeByPeer(Close closeRequest) throws SmackException.NotConnectedException
closeRequest - the close request from the remote peerSmackException.NotConnectedExceptionprotected void closeByLocal(boolean in) throws IOException
IOException - if an error occurs while sending the close requestpublic void processIQPacket(Data data) throws SmackException.NotConnectedException
data - SmackException.NotConnectedException