code: func (t *TerminalHandler) handler(ws *websocket.Conn) {
  	// Create a Teleport client, if not able to, show the reason to the user in
  	// the terminal.
  	tc, err := t.makeClient(ws)
  	if err != nil {
  		er := t.writeError(err, ws)
  		if er != nil {
  			t.log.Warnf("Unable to send error to terminal: %v: %v.", err, er)
  		}
  		return
  	}
  
  	// Create a context for signaling when the terminal session is over.
  	t.terminalContext, t.terminalCancel = context.WithCancel(context.Background())
  
  	t.log.Debugf("Creating websocket stream for %v.", t.params.SessionID)
  
  	// Pump raw terminal in/out and audit events into the websocket.
  	go t.streamTerminal(ws, tc)
  	go t.streamEvents(ws, tc)
  
  	// Block until the terminal session is complete.
  	<-t.terminalContext.Done()
  	t.log.Debugf("Closing websocket stream for %v.", t.params.SessionID)
  }
docs: // handler is the main websocket loop. It creates a Teleport client and then
  // pumps raw events and audit events back to the client until the SSH session
  // is complete.