You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by frank tom <fr...@gmail.com> on 2012/09/17 05:34:41 UTC

refresh the contents on the remote client terminal window

Hi all,
  I am using ssh for remote admin of linux boxes.
  If the user changes the window size, I want the remote client to repaint
the current shell command so that long lines of data will not not be
truncated incorrectly(I use gnome-terminal and putty). I see this could be
possible for I see the following function handleEnv  in
/apache-sshd-0.6.0/src/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java.
All we need to do is to add a listener here to notify the client to do sth
when the server detects the client terminal window size is changed. I think
this is a fancy feature and everyone will like it.:)


/**
 * Define a listener to update the client terminal window
 */
    public interface EnvironmentListener {

        void update();
    }

  Below is my sample code:

       protected boolean handleEnv(Buffer buffer) throws IOException {
        boolean wantReply = buffer.getBoolean();
        String name = buffer.getString();
        String value = buffer.getString();
        addEnvVariable(name, value);

        //do sth on the client
        EnvironmentListener listener =
getEnvironment().getEnvironmentListener();
        if (listener!=null)
        {
        listener.update();
        }
//        notifyListener()?
        log.debug("env for channel {}: {} = {}", new Object[] { id, name,
value });
        if (wantReply) {
            buffer =
session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_SUCCESS, 0);
            buffer.putInt(recipient);
            session.writePacket(buffer);
        }
        return true;
    }

Re: refresh the contents on the remote client terminal window

Posted by Guillaume Nodet <gn...@gmail.com>.
This is already taken care of but by handleWindowChange() in the
ChannelSession object.  You can listen for the changes by adding a
SignalListener on the Environment object.
I know plain properties change can't be listened to in the Environment
object, but in your case it should not be needed at all.

On Mon, Sep 17, 2012 at 5:34 AM, frank tom <fr...@gmail.com> wrote:

> Hi all,
>   I am using ssh for remote admin of linux boxes.
>   If the user changes the window size, I want the remote client to repaint
> the current shell command so that long lines of data will not not be
> truncated incorrectly(I use gnome-terminal and putty). I see this could be
> possible for I see the following function handleEnv  in
>
> /apache-sshd-0.6.0/src/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java.
> All we need to do is to add a listener here to notify the client to do sth
> when the server detects the client terminal window size is changed. I think
> this is a fancy feature and everyone will like it.:)
>
>
> /**
>  * Define a listener to update the client terminal window
>  */
>     public interface EnvironmentListener {
>
>         void update();
>     }
>
>   Below is my sample code:
>
>        protected boolean handleEnv(Buffer buffer) throws IOException {
>         boolean wantReply = buffer.getBoolean();
>         String name = buffer.getString();
>         String value = buffer.getString();
>         addEnvVariable(name, value);
>
>         //do sth on the client
>         EnvironmentListener listener =
> getEnvironment().getEnvironmentListener();
>         if (listener!=null)
>         {
>         listener.update();
>         }
> //        notifyListener()?
>         log.debug("env for channel {}: {} = {}", new Object[] { id, name,
> value });
>         if (wantReply) {
>             buffer =
> session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_SUCCESS, 0);
>             buffer.putInt(recipient);
>             session.writePacket(buffer);
>         }
>         return true;
>     }
>



-- 
------------------------
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
FuseSource, Integration everywhere
http://fusesource.com