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 <[email protected]> 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
