handleMSG_CHANNEL_CLOSE method

void handleMSG_CHANNEL_CLOSE(
  1. MSG_CHANNEL_CLOSE msg
)

Upon receiving this message, a party MUST send back an SSH_MSG_CHANNEL_CLOSE unless it has already sent this message for the channel.

Implementation

void handleMSG_CHANNEL_CLOSE(MSG_CHANNEL_CLOSE msg) {
  if (tracePrint != null) {
    tracePrint('$hostport: MSG_CHANNEL_CLOSE ${msg.recipientChannel}');
  }
  Channel chan = channels[msg.recipientChannel];
  if (chan == null) {
    if (print != null) {
      print('$hostport: Close invalid channel');
      return;
    }
  }

  if (!chan.sentClose) {
    chan.sentClose = true;
    if (chan.closed != null) chan.closed();
    writeCipher(MSG_CHANNEL_CLOSE(chan.remoteId));
    handleChannelClose(chan, 'MSG_CHANNEL_CLOSE');
  }

  channels.remove(msg.recipientChannel);
}