public class Bytestream extends IQ
Modifier and Type | Class and Description |
---|---|
static class |
Bytestream.Activate
The stanza sent by the stream initiator to the stream proxy to activate the connection.
|
static class |
Bytestream.Mode
The stream can be either a TCP stream or a UDP stream.
|
static class |
Bytestream.StreamHost
Stanza extension that represents a potential SOCKS5 proxy for the file transfer.
|
static class |
Bytestream.StreamHostUsed
After selected a SOCKS5 stream host and successfully connecting, the target of the file
transfer returns a byte stream stanza with the stream host used extension.
|
IQ.IQChildElementXmlStringBuilder, IQ.Type
Modifier and Type | Field and Description |
---|---|
static String |
ELEMENT |
static String |
NAMESPACE
The XMPP namespace of the SOCKS5 Bytestream.
|
IQ_ELEMENT, QUERY_ELEMENT
DEFAULT_LANGUAGE, ITEM, language, TEXT
Constructor and Description |
---|
Bytestream()
The default constructor.
|
Bytestream(String SID)
A constructor where the session ID can be specified.
|
Modifier and Type | Method and Description |
---|---|
void |
addStreamHost(Bytestream.StreamHost host)
Adds a potential stream host that the remote user can transfer the file through.
|
Bytestream.StreamHost |
addStreamHost(Jid JID,
String address)
Adds a potential stream host that the remote user can connect to to receive the file.
|
Bytestream.StreamHost |
addStreamHost(Jid JID,
String address,
int port)
Adds a potential stream host that the remote user can connect to to receive the file.
|
int |
countStreamHosts()
Returns the count of stream hosts contained in this packet.
|
protected IQ.IQChildElementXmlStringBuilder |
getIQChildElementBuilder(IQ.IQChildElementXmlStringBuilder xml)
This method must be overwritten by IQ subclasses to create their child content.
|
Bytestream.Mode |
getMode()
Returns the transport mode.
|
String |
getSessionID()
Returns the session ID related to the bytestream negotiation.
|
Bytestream.StreamHost |
getStreamHost(Jid JID)
Returns the stream host related to the given JID, or null if there is none.
|
List<Bytestream.StreamHost> |
getStreamHosts()
Returns the list of stream hosts contained in the packet.
|
Bytestream.Activate |
getToActivate()
Returns the activate element of the stanza sent to the proxy host to verify the identity of
the initiator and match them to the appropriate stream.
|
Bytestream.StreamHostUsed |
getUsedHost()
Returns the SOCKS5 host connected to by the remote user.
|
void |
setMode(Bytestream.Mode mode)
Set the transport mode.
|
void |
setSessionID(String sessionID)
Set the session ID related to the bytestream.
|
void |
setToActivate(Jid targetID)
Upon the response from the target of the used host the activate stanza is sent to the SOCKS5
proxy.
|
void |
setUsedHost(Jid JID)
Upon connecting to the stream host the target of the stream replies to the initiator with the
JID of the SOCKS5 host that they used.
|
createErrorResponse, createErrorResponse, createErrorResponse, createResultIQ, getChildElementName, getChildElementNamespace, getChildElementXML, getChildElementXML, getType, initializeAsResultFor, initialzeAsResultFor, isRequestIQ, setType, toString, toXML
addCommonAttributes, addExtension, addExtensions, appendErrorIfExists, getDefaultLanguage, getError, getExtension, getExtension, getExtensions, getExtensions, getFrom, getLanguage, getPacketID, getStanzaId, getTo, hasExtension, hasExtension, hasStanzaIdSet, logCommonAttributes, overrideExtension, removeExtension, removeExtension, setError, setError, setFrom, setFrom, setLanguage, setPacketID, setStanzaId, setStanzaId, setTo, setTo
public static final String ELEMENT
public static final String NAMESPACE
public Bytestream()
public Bytestream(String SID)
SID
- The session ID related to the negotiation.setSessionID(String)
public void setSessionID(String sessionID)
sessionID
- the unique session ID that identifies the transfer.public String getSessionID()
setSessionID(String)
public void setMode(Bytestream.Mode mode)
mode
- the transport mode, either UDP or TCPBytestream.Mode
public Bytestream.Mode getMode()
setMode(Mode)
public Bytestream.StreamHost addStreamHost(Jid JID, String address)
JID
- The JID of the stream host.address
- The internet address of the stream host.public Bytestream.StreamHost addStreamHost(Jid JID, String address, int port)
JID
- The JID of the stream host.address
- The internet address of the stream host.port
- The port on which the remote host is seeking connections.public void addStreamHost(Bytestream.StreamHost host)
host
- The potential stream host.public List<Bytestream.StreamHost> getStreamHosts()
public Bytestream.StreamHost getStreamHost(Jid JID)
JID
- The JID of the desired stream host.public int countStreamHosts()
public void setUsedHost(Jid JID)
JID
- The JID of the used host.public Bytestream.StreamHostUsed getUsedHost()
public Bytestream.Activate getToActivate()
public void setToActivate(Jid targetID)
targetID
- The JID of the target of the file transfer.protected IQ.IQChildElementXmlStringBuilder getIQChildElementBuilder(IQ.IQChildElementXmlStringBuilder xml)
IQ
IQ.IQChildElementXmlStringBuilder
after eventual existing ExtensionElement
s have been added.
For example to create an IQ with a extra attribute and an additional child element
<iq to='foo@example.org' id='123'>
<bar xmlns='example:bar' extraAttribute='blaz'>
<extraElement>elementText</extraElement>
</bar>
</iq>
the body of the getIQChildElementBuilder
looks like
// The builder 'xml' will already have the child element and the 'xmlns' attribute added
// So the current builder state is "<bar xmlns='example:bar'"
xml.attribute("extraAttribute", "blaz");
xml.rightAngleBracket();
xml.element("extraElement", "elementText");
// Do not close the 'bar' attribute by calling xml.closeElement('bar')
If your IQ only contains attributes and no child elements, i.e. it can be represented as empty element, then you
can mark it as such.
xml.attribute("myAttribute", "myAttributeValue"); xml.setEmptyElement();If your IQ does not contain any attributes or child elements (besides
ExtensionElement
s), consider sub-classing
SimpleIQ
instead.getIQChildElementBuilder
in class IQ
xml
- a pre-created builder which already has the child element and the 'xmlns' attribute set.