protected boolean processChannelMessage(SshChannelMessage msg)
			throws SshException {

		try {
			switch (msg.getMessageId()) {
			case SSH_MSG_CHANNEL_REQUEST:

				String requesttype = msg.readString();
				boolean wantreply = msg.read() != 0;
				byte[] requestdata = new byte[msg.available()];
				msg.read(requestdata);

				if (Log.isDebugEnabled()) {
					Log.debug(this,
							"Received SSH_MSG_CHANNEL_REQUEST id=" + channelid
									+ " rid=" + remoteid + " request="
									+ requesttype + " wantreply=" + wantreply);
				}
				channelRequest(requesttype, wantreply, requestdata);
				return true;
			case SSH_MSG_WINDOW_ADJUST:

				if (Log.isDebugEnabled()) {
					msg.mark(4);
					int len = (int) msg.readInt();
					Log.debug(this,
							"Received SSH_MSG_WINDOW_ADJUST id=" + channelid
									+ " rid=" + remoteid + " window="
									+ remotewindow.available() + " adjust="
									+ len);
					msg.reset();
				}

				return false;
			case SSH_MSG_CHANNEL_DATA:

				if (Log.isDebugEnabled()) {
					Log.debug(
							this,
							"Received SSH_MSG_CHANNEL_DATA id=" + channelid
									+ " rid=" + remoteid + " len="
									+ (msg.available() - 4) + " window="
									+ localwindow.available());
				}

				// Is the channels InputStream currently in a blocking read
				// operation? if it is then we can leave the message for it
				// to process (and subsequently break out of the block) or
				// if not we should process it here so that data events
				// are fired in a timely fashion
				if (autoConsumeInput) {
					localwindow.consume(msg.available() - 4);
					if (localwindow.available() <= localwindow.getInitialSize() / 2) {
						adjustWindow(localwindow.getInitialSize()
								- localwindow.available());
					}
				}

				for (Enumeration<ChannelEventListener> e = listeners.elements(); e
						.hasMoreElements();) {
					(e.nextElement()).dataReceived(Ssh2Channel.this,
							msg.array(), msg.getPosition() + 4,
							msg.available() - 4);
				}

				return autoConsumeInput;

			case SSH_MSG_CHANNEL_EXTENDED_DATA:

				if (Log.isDebugEnabled()) {
					Log.debug(this,
							"Received SSH_MSG_CHANNEL_EXTENDED_DATA id="
									+ channelid + " rid=" + remoteid + " len="
									+ (msg.available() - 4) + " window="
									+ localwindow.available());
				}

				int type = (int) ByteArrayReader.readInt(msg.array(),
						msg.getPosition());

				if (autoConsumeInput) {
					localwindow.consume(msg.available() - 8);
					if (localwindow.available() <= localwindow.getInitialSize() / 2) {
						adjustWindow(localwindow.getInitialSize()
								- localwindow.available());
					}
				}

				for (Enumeration<ChannelEventListener> e = listeners.elements(); e
						.hasMoreElements();) {
					(e.nextElement()).extendedDataReceived(Ssh2Channel.this,
							msg.array(), msg.getPosition() + 8,
							msg.available() - 8, type);
				}

				return autoConsumeInput;

			case SSH_MSG_CHANNEL_CLOSE:

				if (Log.isDebugEnabled()) {
					Log.debug(this,
							"Received SSH_MSG_CHANNEL_CLOSE id=" + channelid
									+ " rid=" + remoteid);
				}

				// Synchronize on message store and close
				synchronized (this) {
					if (!closing) {
						synchronized (ms) {
							if (!ms.isClosed())
								ms.close();
						}
					}
				}

				checkCloseStatus(true);
				return false;

			case SSH_MSG_CHANNEL_EOF:

				if (Log.isDebugEnabled()) {
					Log.debug(this, "Received SSH_MSG_CHANNEL_EOF id="
							+ channelid + " rid=" + remoteid);
				}

				isRemoteEOF = true;

				for (Enumeration<ChannelEventListener> e = listeners.elements(); e
						.hasMoreElements();) {
					(e.nextElement()).channelEOF(Ssh2Channel.this);
				}

				// Fire the EOF event, do we need this on the listener?
				channelEOF();

				if (isLocalEOF) {
					close();
				}
				return false;

			default:
				return false;
			}
		} catch (IOException ex) {
			throw new SshException(ex, SshException.INTERNAL_ERROR);
		}

	}
protected boolean processChannelMessage ( SshChannelMessage msg ) throws SshException { try { switch ( msg . getMessageId ( ) ) { case SSH_MSG_CHANNEL_REQUEST : String requesttype = msg . readString ( ) ; boolean wantreply = msg . read ( ) != 0 ; byte [ ] requestdata = new byte [ msg . available ( ) ] ; msg . read ( requestdata ) ; if ( Log . isDebugEnabled ( ) ) { Log . debug ( this , "Received SSH_MSG_CHANNEL_REQUEST id=" + channelid + " rid=" + remoteid + " request=" + requesttype + " wantreply=" + wantreply ) ; } channelRequest ( requesttype , wantreply , requestdata ) ; return true ; case SSH_MSG_WINDOW_ADJUST : if ( Log . isDebugEnabled ( ) ) { msg . mark ( 4 ) ; int len = ( int ) msg . readInt ( ) ; Log . debug ( this , "Received SSH_MSG_WINDOW_ADJUST id=" + channelid + " rid=" + remoteid + " window=" + remotewindow . available ( ) + " adjust=" + len ) ; msg . reset ( ) ; } return false ; case SSH_MSG_CHANNEL_DATA : if ( Log . isDebugEnabled ( ) ) { Log . debug ( this , "Received SSH_MSG_CHANNEL_DATA id=" + channelid + " rid=" + remoteid + " len=" + ( msg . available ( ) - 4 ) + " window=" + localwindow . available ( ) ) ; } if ( autoConsumeInput ) { localwindow . consume ( msg . available ( ) - 4 ) ; if ( localwindow . available ( ) <= localwindow . getInitialSize ( ) / 2 ) { adjustWindow ( localwindow . getInitialSize ( ) - localwindow . available ( ) ) ; } } for ( Enumeration < ChannelEventListener > e = listeners . elements ( ) ; e . hasMoreElements ( ) ; ) { ( e . nextElement ( ) ) . dataReceived ( Ssh2Channel . this , msg . array ( ) , msg . getPosition ( ) + 4 , msg . available ( ) - 4 ) ; } return autoConsumeInput ; case SSH_MSG_CHANNEL_EXTENDED_DATA : if ( Log . isDebugEnabled ( ) ) { Log . debug ( this , "Received SSH_MSG_CHANNEL_EXTENDED_DATA id=" + channelid + " rid=" + remoteid + " len=" + ( msg . available ( ) - 4 ) + " window=" + localwindow . available ( ) ) ; } int type = ( int ) ByteArrayReader . readInt ( msg . array ( ) , msg . getPosition ( ) ) ; if ( autoConsumeInput ) { localwindow . consume ( msg . available ( ) - 8 ) ; if ( localwindow . available ( ) <= localwindow . getInitialSize ( ) / 2 ) { adjustWindow ( localwindow . getInitialSize ( ) - localwindow . available ( ) ) ; } } for ( Enumeration < ChannelEventListener > e = listeners . elements ( ) ; e . hasMoreElements ( ) ; ) { ( e . nextElement ( ) ) . extendedDataReceived ( Ssh2Channel . this , msg . array ( ) , msg . getPosition ( ) + 8 , msg . available ( ) - 8 , type ) ; } return autoConsumeInput ; case SSH_MSG_CHANNEL_CLOSE : if ( Log . isDebugEnabled ( ) ) { Log . debug ( this , "Received SSH_MSG_CHANNEL_CLOSE id=" + channelid + " rid=" + remoteid ) ; } synchronized ( this ) { if ( ! closing ) { synchronized ( ms ) { if ( ! ms . isClosed ( ) ) ms . close ( ) ; } } } checkCloseStatus ( true ) ; return false ; case SSH_MSG_CHANNEL_EOF : if ( Log . isDebugEnabled ( ) ) { Log . debug ( this , "Received SSH_MSG_CHANNEL_EOF id=" + channelid + " rid=" + remoteid ) ; } isRemoteEOF = true ; for ( Enumeration < ChannelEventListener > e = listeners . elements ( ) ; e . hasMoreElements ( ) ; ) { ( e . nextElement ( ) ) . channelEOF ( Ssh2Channel . this ) ; } channelEOF ( ) ; if ( isLocalEOF ) { close ( ) ; } return false ; default : return false ; } } catch ( IOException ex ) { throw new SshException ( ex , SshException . INTERNAL_ERROR ) ; } }
Processes channel request messages by passing the request through to <a
href
="#channelRequest(java.lang.String, boolean, byte[])">channelRequest()
</a>.