code: func (t *TerminalHandler) streamTerminal(ws *websocket.Conn, tc *client.TeleportClient) {
  	defer t.terminalCancel()
  
  	// Establish SSH connection to the server. This function will block until
  	// either an error occurs or it completes successfully.
  	err := tc.SSH(t.terminalContext, t.params.InteractiveCommand, false)
  	if err != nil {
  		t.log.Warnf("Unable to stream terminal: %v.", err)
  		er := t.writeError(err, ws)
  		if er != nil {
  			t.log.Warnf("Unable to send error to terminal: %v: %v.", err, er)
  		}
  		return
  	}
  
  	// Send close envelope to web terminal upon exit without an error.
  	envelope := &Envelope{
  		Version: defaults.WebsocketVersion,
  		Type:    defaults.WebsocketClose,
  		Payload: "",
  	}
  	envelopeBytes, err := proto.Marshal(envelope)
  	if err != nil {
  		t.log.Errorf("Unable to marshal close event for web client.")
  		return
  	}
  	err = websocket.Message.Send(ws, envelopeBytes)
  	if err != nil {
  		t.log.Errorf("Unable to send close event to web client.")
  		return
  	}
  	t.log.Debugf("Sent close event to web client.")
  }
docs: // streamTerminal opens a SSH connection to the remote host and streams
  // events back to the web client.