code: func (h *HandlerService) Handle(conn net.Conn) {
  	// create a client agent and startup write goroutine
  	a := agent.NewAgent(conn, h.decoder, h.encoder, h.serializer, h.heartbeatTimeout, h.messagesBufferSize, h.appDieChan, h.messageEncoder, h.metricsReporters)
  
  	// startup agent goroutine
  	go a.Handle()
  
  	logger.Log.Debugf("New session established: %s", a.String())
  
  	// guarantee agent related resource is destroyed
  	defer func() {
  		a.Session.Close()
  		logger.Log.Debugf("Session read goroutine exit, SessionID=%d, UID=%d", a.Session.ID(), a.Session.UID())
  	}()
  
  	// read loop
  	buf := make([]byte, 2048)
  	for {
  		n, err := conn.Read(buf)
  		if err != nil {
  			logger.Log.Debugf("Read message error: %s, session will be closed immediately", err.Error())
  			return
  		}
  
  		logger.Log.Debug("Received data on connection")
  
  		// (warning): decoder uses slice for performance, packet data should be copied before next Decode
  		packets, err := h.decoder.Decode(buf[:n])
  		if err != nil {
  			logger.Log.Errorf("Failed to decode message: %s", err.Error())
  			return
  		}
  
  		if len(packets) < 1 {
  			logger.Log.Warnf("Read no packets, data: %v", buf[:n])
  			continue
  		}
  
  		// process all packet
  		for i := range packets {
  			if err := h.processPacket(a, packets[i]); err != nil {
  				logger.Log.Errorf("Failed to process packet: %s", err.Error())
  				return
  			}
  		}
  	}
  }
docs: // Handle handles messages from a conn