code: func DialXHR(uri string, cfg *config.Config) (*XHRSession, error) {
  	// following /server_id/session_id should always be the same for every session
  	serverID := threeDigits()
  	sessionID := utils.RandomString(20)
  	sessionURL := uri + "/" + serverID + "/" + sessionID
  
  	// start the initial session handshake
  	sessionResp, err := cfg.XHR.Post(sessionURL+"/xhr", "text/plain", nil)
  	if err != nil {
  		return nil, err
  	}
  	defer sessionResp.Body.Close()
  
  	if sessionResp.StatusCode != http.StatusOK {
  		return nil, fmt.Errorf("Starting new session failed. Want: %d Got: %d",
  			http.StatusOK, sessionResp.StatusCode)
  	}
  
  	frame, err := newFrameReader(sessionResp.Body, cfg.Timeout).ReadByte()
  	if err != nil {
  		return nil, err
  	}
  
  	if frame != 'o' {
  		return nil, fmt.Errorf("can't start session, invalid frame: %s", string(frame))
  	}
  
  	return &XHRSession{
  		client:     cfg.XHR,
  		timeout:    cfg.Timeout,
  		sessionID:  sessionID,
  		sessionURL: sessionURL,
  		state:      sockjs.SessionActive,
  		abort:      make(chan struct{}, 1),
  	}, nil
  }
docs: // DialXHR establishes a SockJS session over a XHR connection.
  //
  // Requires cfg.XHR to be a valid client.