func (session *Session) HandleRequest(writer http.ResponseWriter, request *http.Request) {
	defer request.Body.Close()

	query := request.URL.Query()
	requestedTransport := query.Get("transport")

	if !session.transportSupported(requestedTransport) {
		logger.Error("Transport ", requestedTransport, " is not supported")

		writer.WriteHeader(http.StatusBadRequest)
		return
	}

	if session.transport == nil {
		session.transport = session.createTransport(requestedTransport)
	}

	if !session.handshaked {
		go session.handshake()
	}

	if session.isUpgradeRequest(requestedTransport) {
		err := session.upgrade(writer, request, requestedTransport)

		if err != nil {
			logger.Error("Transport upgrade error: ", err)
			writer.WriteHeader(http.StatusBadRequest)
		}

		return
	}

	session.transport.HandleRequest(writer, request)
}
// HandleRequest is the bridge between the engine.io endpoint and the selected transport
HandleRequest is the bridge between the engine.io endpoint and the selected transport
// HandleRequest is the bridge between the engine . io endpoint and the selected transport
func (session *Session) HandleRequest(writer http.ResponseWriter, request *http.Request) {
	defer request.Body.Close()
	query := request.URL.Query()
	requestedTransport := query.Get("transport")
	if !session.transportSupported(requestedTransport) {
		logger.Error("Transport ", requestedTransport, " is not supported")
		writer.WriteHeader(http.StatusBadRequest)
		return
	}
	if session.transport == nil {
		session.transport = session.createTransport(requestedTransport)
	}
	if !session.handshaked {
		go session.handshake()
	}
	if session.isUpgradeRequest(requestedTransport) {
		err := session.upgrade(writer, request, requestedTransport)
		if err != nil {
			logger.Error("Transport upgrade error: ", err)
			writer.WriteHeader(http.StatusBadRequest)
		}
		return
	}
	session.transport.HandleRequest(writer, request)
}
func ( session * Session ) HandleRequest ( writer http . ResponseWriter , request * http . Request ) { defer request . Body . Close ( ) query := request . URL . Query ( ) requestedTransport := query . Get ( " " ) if ! session . transportSupported ( requestedTransport ) { logger . Error ( " " , requestedTransport , " " ) writer . WriteHeader ( http . StatusBadRequest ) return } if session . transport == nil { session . transport = session . createTransport ( requestedTransport ) } if ! session . handshaked { go session . handshake ( ) } if session . isUpgradeRequest ( requestedTransport ) { err := session . upgrade ( writer , request , requestedTransport ) if err != nil { logger . Error ( " " , err ) writer . WriteHeader ( http . StatusBadRequest ) } return } session . transport . HandleRequest ( writer , request ) }
HandleRequest is the bridge between the engine.io endpoint and the selected transport
HandleRequest is the bridge between the engine . io endpoint and the selected transport