code: func NewAgent(
  	conn net.Conn,
  	packetDecoder codec.PacketDecoder,
  	packetEncoder codec.PacketEncoder,
  	serializer serialize.Serializer,
  	heartbeatTime time.Duration,
  	messagesBufferSize int,
  	dieChan chan bool,
  	messageEncoder message.Encoder,
  	metricsReporters []metrics.Reporter,
  ) *Agent {
  	// initialize heartbeat and handshake data on first user connection
  	once.Do(func() {
  		hbdEncode(heartbeatTime, packetEncoder, messageEncoder.IsCompressionEnabled(), serializer.GetName())
  	})
  
  	a := &Agent{
  		appDieChan:         dieChan,
  		chDie:              make(chan struct{}),
  		chSend:             make(chan pendingMessage, messagesBufferSize),
  		chStopHeartbeat:    make(chan struct{}),
  		chStopWrite:        make(chan struct{}),
  		messagesBufferSize: messagesBufferSize,
  		conn:               conn,
  		decoder:            packetDecoder,
  		encoder:            packetEncoder,
  		heartbeatTimeout:   heartbeatTime,
  		lastAt:             time.Now().Unix(),
  		serializer:         serializer,
  		state:              constants.StatusStart,
  		messageEncoder:     messageEncoder,
  		metricsReporters:   metricsReporters,
  	}
  
  	// binding session
  	s := session.New(a, true)
  	metrics.ReportNumberOfConnectedClients(metricsReporters, session.SessionCount)
  	a.Session = s
  	return a
  }
docs: // NewAgent create new agent instance