Class ConnectionImpl

    • Constructor Detail

      • ConnectionImpl

        public ConnectionImpl​(Transport trans,
                              KeepAliveProvider keepAlive)
        Create with an associated Transport.
        Parameters:
        trans - transport layer
        keepAlive - the keep alive provider
    • Method Detail

      • attach

        public void attach​(Channel chan)
        Description copied from interface: Connection
        Attach a Channel to this connection. A channel must be attached to the connection if it is to receive any channel-specific data that is received.
        Specified by:
        attach in interface Connection
        Parameters:
        chan - the channel
      • get

        public Channel get​(int id)
        Specified by:
        get in interface Connection
        Parameters:
        id - number of the channel to retrieve
        Returns:
        an attached Channel of specified channel number, or null if no such channel was attached
      • forget

        public void forget​(Channel chan)
        Description copied from interface: Connection
        Forget an attached Channel.
        Specified by:
        forget in interface Connection
        Parameters:
        chan - the channel
      • getMaxPacketSize

        public int getMaxPacketSize()
        Specified by:
        getMaxPacketSize in interface Connection
        Returns:
        the maximum packet size for the local window this connection recommends to any Channel's that ask for it.
      • setMaxPacketSize

        public void setMaxPacketSize​(int maxPacketSize)
        Description copied from interface: Connection
        Set the maximum packet size for the local window this connection recommends to any Channel's that ask for it.
        Specified by:
        setMaxPacketSize in interface Connection
        Parameters:
        maxPacketSize - maximum packet size in bytes
      • getWindowSize

        public long getWindowSize()
        Specified by:
        getWindowSize in interface Connection
        Returns:
        the size for the local window this connection recommends to any Channel's that ask for it.
      • setWindowSize

        public void setWindowSize​(long windowSize)
        Description copied from interface: Connection
        Set the size for the local window this connection recommends to any Channel's that ask for it.
        Specified by:
        setWindowSize in interface Connection
        Parameters:
        windowSize - window size in bytes
      • join

        public void join()
                  throws java.lang.InterruptedException
        Description copied from interface: Connection
        Wait for the situation that no channels are attached (e.g., got closed).
        Specified by:
        join in interface Connection
        Throws:
        java.lang.InterruptedException - if the thread is interrupted
      • nextID

        public int nextID()
        Specified by:
        nextID in interface Connection
        Returns:
        an available ID a Channel can rightfully claim.
      • sendGlobalRequest

        public Promise<SSHPacket,​ConnectionException> sendGlobalRequest​(java.lang.String name,
                                                                              boolean wantReply,
                                                                              byte[] specifics)
                                                                       throws TransportException
        Description copied from interface: Connection
        Send an SSH global request.
        Specified by:
        sendGlobalRequest in interface Connection
        Parameters:
        name - request name
        wantReply - whether a reply is requested
        specifics - SSHPacket containing fields specific to the request
        Returns:
        a Promise for the reply data (in case wantReply is true) which allows waiting on the reply, or null if a reply is not requested.
        Throws:
        TransportException - if there is an error sending the request
      • sendOpenFailure

        public void sendOpenFailure​(int recipient,
                                    OpenFailException.Reason reason,
                                    java.lang.String message)
                             throws TransportException
        Description copied from interface: Connection
        Send a SSH_MSG_OPEN_FAILURE for specified Reason and message.
        Specified by:
        sendOpenFailure in interface Connection
        Parameters:
        recipient - number of the recipient channel
        reason - a reason for the failure
        message - an explanatory message
        Throws:
        TransportException - if there is a transport-layer error
      • setTimeoutMs

        public void setTimeoutMs​(int timeoutMs)
        Description copied from interface: Connection
        Set the timeout this connection uses for blocking operations and recommends to any other classes that ask for it.
        Specified by:
        setTimeoutMs in interface Connection
        Parameters:
        timeoutMs - timeout in milliseconds
      • getTimeoutMs

        public int getTimeoutMs()
        Specified by:
        getTimeoutMs in interface Connection
        Returns:
        the timeout in milliseconds that this connection uses for blocking operations and recommends to any other classes that ask for it.