Class StreamNegotiator

java.lang.Object
org.jivesoftware.smack.Manager
org.jivesoftware.smackx.filetransfer.StreamNegotiator
Direct Known Subclasses:
IBBTransferNegotiator, Socks5TransferNegotiator

public abstract class StreamNegotiator extends org.jivesoftware.smack.Manager
After the file transfer negotiation process is completed according to XEP-0096, the negotiation process is passed off to a particular stream negotiator. The stream negotiator will then negotiate the chosen stream and return the stream to transfer the file.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final org.jivesoftware.smack.util.EventManger<String,org.jivesoftware.smack.packet.IQ,org.jivesoftware.smack.SmackException.NotConnectedException>
    An event manager for stream initiation requests send to us.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    StreamNegotiator(org.jivesoftware.smack.XMPPConnection connection)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract InputStream
    This method handles the file stream download negotiation process.
    protected static StreamInitiation
    createInitiationAccept(StreamInitiation streamInitiationOffer, String namespace)
    Creates the initiation acceptance stanza to forward to the stream initiator.
    abstract OutputStream
    createOutgoingStream(String streamID, org.jxmpp.jid.Jid initiator, org.jxmpp.jid.Jid target)
    This method handles the file upload stream negotiation process.
    abstract String
    Returns the XMPP namespace reserved for this particular type of file transfer.
    protected final org.jivesoftware.smack.packet.IQ
    initiateIncomingStream(org.jivesoftware.smack.XMPPConnection connection, StreamInitiation initiation)
     
    protected abstract void
    newStreamInitiation(org.jxmpp.jid.Jid from, String streamID)
    Signal that a new stream initiation arrived.
    static void
    signal(String eventKey, org.jivesoftware.smack.packet.IQ eventValue)
     

    Methods inherited from class org.jivesoftware.smack.Manager

    connection, getAuthenticatedConnectionOrThrow, schedule, schedule, scheduleBlocking

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • initationSetEvents

      protected static final org.jivesoftware.smack.util.EventManger<String,org.jivesoftware.smack.packet.IQ,org.jivesoftware.smack.SmackException.NotConnectedException> initationSetEvents
      An event manager for stream initiation requests send to us.

      Those are typical XEP-45 Open or XEP-65 Bytestream IQ requests. The even key is in the format "initiationFrom + '\t' + streamId"

  • Constructor Details

    • StreamNegotiator

      protected StreamNegotiator(org.jivesoftware.smack.XMPPConnection connection)
  • Method Details

    • createInitiationAccept

      protected static StreamInitiation createInitiationAccept(StreamInitiation streamInitiationOffer, String namespace)
      Creates the initiation acceptance stanza to forward to the stream initiator.
      Parameters:
      streamInitiationOffer - The offer from the stream initiator to connect for a stream.
      namespace - The namespace that relates to the accepted means of transfer.
      Returns:
      The response to be forwarded to the initiator.
    • initiateIncomingStream

      protected final org.jivesoftware.smack.packet.IQ initiateIncomingStream(org.jivesoftware.smack.XMPPConnection connection, StreamInitiation initiation) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException
      Throws:
      org.jivesoftware.smack.SmackException.NoResponseException
      org.jivesoftware.smack.XMPPException.XMPPErrorException
      org.jivesoftware.smack.SmackException.NotConnectedException
    • newStreamInitiation

      protected abstract void newStreamInitiation(org.jxmpp.jid.Jid from, String streamID)
      Signal that a new stream initiation arrived. The negotiator may needs to prepare for it.
      Parameters:
      from - The initiator of the file transfer.
      streamID - The stream ID related to the transfer.
    • createIncomingStream

      public abstract InputStream createIncomingStream(StreamInitiation initiation) throws org.jivesoftware.smack.XMPPException.XMPPErrorException, InterruptedException, org.jivesoftware.smack.SmackException
      This method handles the file stream download negotiation process. The appropriate stream negotiator's initiate incoming stream is called after an appropriate file transfer method is selected. The manager will respond to the initiator with the selected means of transfer, then it will handle any negotiation specific to the particular transfer method. This method returns the InputStream, ready to transfer the file.
      Parameters:
      initiation - The initiation that triggered this download.
      Returns:
      After the negotiation process is complete, the InputStream to write a file to is returned.
      Throws:
      org.jivesoftware.smack.XMPPException.XMPPErrorException - If an error occurs during this process an XMPPException is thrown.
      InterruptedException - If thread is interrupted.
      org.jivesoftware.smack.SmackException - if Smack detected an exceptional situation.
    • createOutgoingStream

      public abstract OutputStream createOutgoingStream(String streamID, org.jxmpp.jid.Jid initiator, org.jxmpp.jid.Jid target) throws org.jivesoftware.smack.SmackException, org.jivesoftware.smack.XMPPException, InterruptedException
      This method handles the file upload stream negotiation process. The particular stream negotiator is determined during the file transfer negotiation process. This method returns the OutputStream to transmit the file to the remote user.
      Parameters:
      streamID - The streamID that uniquely identifies the file transfer.
      initiator - The fully-qualified JID of the initiator of the file transfer.
      target - The fully-qualified JID of the target or receiver of the file transfer.
      Returns:
      The negotiated stream ready for data.
      Throws:
      org.jivesoftware.smack.SmackException - if Smack detected an exceptional situation.
      org.jivesoftware.smack.XMPPException - if an XMPP protocol error was received.
      InterruptedException - if the calling thread was interrupted.
    • getNamespace

      public abstract String getNamespace()
      Returns the XMPP namespace reserved for this particular type of file transfer.
      Returns:
      Returns the XMPP namespace reserved for this particular type of file transfer.
    • signal

      public static void signal(String eventKey, org.jivesoftware.smack.packet.IQ eventValue)