Class InBandBytestreamSession
java.lang.Object
org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamSession
- All Implemented Interfaces:
BytestreamSession
InBandBytestreamSession class represents an In-Band Bytestream session.
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.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInBandBytestreamSession(XMPPConnection connection, Open byteStreamRequest, Jid remoteJID) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the bytestream session.protected voidcloseByLocal(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 voidcloseByPeer(Close closeRequest) This method is invoked if a request to close the In-Band Bytestream has been received.Returns the InputStream associated with this session to send data.Returns the OutputStream associated with this session to receive data.intReturns the timeout for read operations of the input stream associated with this session.booleanReturns whether both streams should be closed automatically if one of the streams is closed.voidprocessIQPacket(Data data) Process IQ stanza.voidsetCloseBothStreamsEnabled(boolean closeBothStreamsEnabled) Sets whether both streams should be closed automatically if one of the streams is closed.voidsetReadTimeout(int timeout) Sets the specified timeout, in milliseconds.
-
Constructor Details
-
InBandBytestreamSession
Constructor.- Parameters:
connection- the XMPP connectionbyteStreamRequest- the In-Band Bytestream open request for this sessionremoteJID- JID of the remote peer
-
-
Method Details
-
getInputStream
Description copied from interface:BytestreamSessionReturns the InputStream associated with this session to send data.- Specified by:
getInputStreamin interfaceBytestreamSession- Returns:
- the InputStream associated with this session to send data
-
getOutputStream
Description copied from interface:BytestreamSessionReturns the OutputStream associated with this session to receive data.- Specified by:
getOutputStreamin interfaceBytestreamSession- Returns:
- the OutputStream associated with this session to receive data
-
getReadTimeout
Description copied from interface:BytestreamSessionReturns the timeout for read operations of the input stream associated with this session. 0 returns implies that the option is disabled (i.e., timeout of infinity). Default is 0.- Specified by:
getReadTimeoutin interfaceBytestreamSession- Returns:
- the timeout for read operations
-
setReadTimeout
Description copied from interface:BytestreamSessionSets the specified timeout, in milliseconds. With this option set to a non-zero timeout, a read() call on the input stream associated with this session will block for only this amount of time. If the timeout expires, a java.net.SocketTimeoutException is raised, though the session is still valid. The option must be enabled prior to entering the blocking operation to have effect. The timeout must be > 0. A timeout of zero is interpreted as an infinite timeout. Default is 0.- Specified by:
setReadTimeoutin interfaceBytestreamSession- Parameters:
timeout- the specified timeout, in milliseconds
-
isCloseBothStreamsEnabled
Returns whether both streams should be closed automatically if one of the streams is closed. Default isfalse.- Returns:
trueif both streams will be closed if one of the streams is closed,falseif both streams can be closed independently.
-
setCloseBothStreamsEnabled
Sets whether both streams should be closed automatically if one of the streams is closed. Default isfalse.- Parameters:
closeBothStreamsEnabled-trueif both streams should be closed if one of the streams is closed,falseif both streams should be closed independently
-
close
Description copied from interface:BytestreamSessionCloses the bytestream session.Closing the session will also close the input stream and the output stream associated to this session.
- Specified by:
closein interfaceBytestreamSession- Throws:
IOException- if an error occurs while closing the session
-
closeByPeer
protected void closeByPeer(Close closeRequest) throws SmackException.NotConnectedException, InterruptedException This method is invoked if a request to close the In-Band Bytestream has been received.- Parameters:
closeRequest- the close request from the remote peer- Throws:
SmackException.NotConnectedException- if the XMPP connection is not connected.InterruptedException- if the calling thread was interrupted.
-
closeByLocal
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.- Parameters:
in- do we want to close the Input- or OutputStream?- Throws:
IOException- if an error occurs while sending the close request
-
processIQPacket
public void processIQPacket(Data data) throws SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException Process IQ stanza.- Parameters:
data- TODO javadoc me please- Throws:
SmackException.NotConnectedException- if the XMPP connection is not connected.InterruptedException- if the calling thread was interrupted.SmackException.NotLoggedInException- if the XMPP connection is not authenticated.
-