Search in sources :

Example 1 with PTYMode

use of com.jn.agileway.ssh.client.utils.PTYMode in project agileway by fangjinuo.

the class SshjSessionedChannel method pty.

@Override
public void pty(String term, int termWidthCharacters, int termHeightCharacters, int termWidthPixels, int termHeightPixels, Map<PTYMode, Integer> terminalModes) throws SshException {
    final Map<net.schmizz.sshj.connection.channel.direct.PTYMode, Integer> terminalModeMap = new HashMap<net.schmizz.sshj.connection.channel.direct.PTYMode, Integer>();
    Collects.forEach(terminalModes, new Consumer2<PTYMode, Integer>() {

        @Override
        public void accept(PTYMode ptyMode, Integer value) {
            String operateName = ptyMode.name();
            net.schmizz.sshj.connection.channel.direct.PTYMode mode = Enums.ofName(net.schmizz.sshj.connection.channel.direct.PTYMode.class, operateName);
            if (mode != null) {
                terminalModeMap.put(mode, value);
            }
        }
    });
    try {
        this.session.allocatePTY(term, termWidthCharacters, termHeightCharacters, termWidthPixels, termHeightPixels, terminalModeMap);
    } catch (Throwable ex) {
        throw new SshException(ex);
    }
}
Also used : HashMap(java.util.HashMap) SshException(com.jn.agileway.ssh.client.SshException) PTYMode(com.jn.agileway.ssh.client.utils.PTYMode)

Example 2 with PTYMode

use of com.jn.agileway.ssh.client.utils.PTYMode in project agileway by fangjinuo.

the class SynergySessionedChannel method pty.

@Override
public void pty(String term, int termWidthCharacters, int termHeightCharacters, int termWidthPixels, int termHeightPixels, Map<PTYMode, Integer> terminalModes) throws SshException {
    final PseudoTerminalModes modes = new PseudoTerminalModes();
    if (terminalModes != null) {
        Collects.forEach(terminalModes, new Consumer2<PTYMode, Integer>() {

            @Override
            public void accept(PTYMode ptyMode, Integer value) {
                try {
                    modes.setTerminalMode(ptyMode.getOpcodeInt(), value);
                } catch (Throwable ex) {
                // ignore it
                }
            }
        });
    }
    this.channel.allocatePseudoTerminal(term, termWidthCharacters, termHeightCharacters, termWidthPixels, termHeightPixels, modes);
}
Also used : PseudoTerminalModes(com.sshtools.client.PseudoTerminalModes) PTYMode(com.jn.agileway.ssh.client.utils.PTYMode)

Aggregations

PTYMode (com.jn.agileway.ssh.client.utils.PTYMode)2 SshException (com.jn.agileway.ssh.client.SshException)1 PseudoTerminalModes (com.sshtools.client.PseudoTerminalModes)1 HashMap (java.util.HashMap)1