code: func (s *SessionRegistry) OpenSession(ch ssh.Channel, req *ssh.Request, ctx *ServerContext) error {
  	if ctx.session != nil {
  		ctx.Infof("Joining existing session %v.", ctx.session.id)
  
  		// Update the in-memory data structure that a party member has joined.
  		_, err := ctx.session.join(ch, req, ctx)
  		if err != nil {
  			return trace.Wrap(err)
  		}
  
  		// Emit session join event to both the Audit Log as well as over the
  		// "x-teleport-event" channel in the SSH connection.
  		s.emitSessionJoinEvent(ctx)
  
  		return nil
  	}
  	// session not found? need to create one. start by getting/generating an ID for it
  	sid, found := ctx.GetEnv(sshutils.SessionEnvVar)
  	if !found {
  		sid = string(rsession.NewID())
  		ctx.SetEnv(sshutils.SessionEnvVar, sid)
  	}
  	// This logic allows concurrent request to create a new session
  	// to fail, what is ok because we should never have this condition
  	sess, err := newSession(rsession.ID(sid), s, ctx)
  	if err != nil {
  		return trace.Wrap(err)
  	}
  	ctx.session = sess
  	s.addSession(sess)
  	ctx.Infof("Creating session %v.", sid)
  
  	if err := sess.start(ch, ctx); err != nil {
  		sess.Close()
  		return trace.Wrap(err)
  	}
  	return nil
  }
docs: // OpenSession either joins an existing session or starts a new session.