func (s *Session) listenReply(resultChan chan contracts.DocumentResult, instanceId string) {
	log := s.context.Log()
	log.Info("listening reply.")

	//processor guarantees to close this channel upon stop
	for res := range resultChan {
		if res.LastPlugin != "" {
			log.Infof("received plugin: %s result from Processor", res.LastPlugin)
		} else {
			log.Infof("session: %s complete", res.MessageID)

			//Deleting Old Log Files
			instanceID, _ := platform.InstanceID()
			go docmanager.DeleteSessionOrchestrationDirectories(log,
				instanceID,
				s.context.AppConfig().Agent.OrchestrationRootDir,
				s.context.AppConfig().Ssm.SessionLogsRetentionDurationHours)
		}
		if s.context.AppConfig().Agent.ContainerMode {
			instanceId, _ = platform.TargetID()
		}
		msg, err := buildAgentTaskComplete(log, res, instanceId)
		if err != nil {
			log.Errorf("Cannot build AgentTaskComplete message %s", err)
			return
		}

		// For last document level result, no need to send reply because there will be only one plugin for shell plugin case.
		if msg != nil {
			err = s.controlChannel.SendMessage(log, msg, websocket.BinaryMessage)
			if err != nil {
				log.Errorf("Error sending reply message %v", err)
			}
		}
	}
}
// listenReply listens document result of session execution.
listenReply listens document result of session execution.
// listenReply listens document result of session execution .
func (s *Session) listenReply(resultChan chan contracts.DocumentResult, instanceId string) {
	log := s.context.Log()
	log.Info("listening reply.")
	for res := range resultChan {
		if res.LastPlugin != "" {
			log.Infof("received plugin: %s result from Processor", res.LastPlugin)
		} else {
			log.Infof("session: %s complete", res.MessageID)
			instanceID, _ := platform.InstanceID()
			go docmanager.DeleteSessionOrchestrationDirectories(log,
				instanceID,
				s.context.AppConfig().Agent.OrchestrationRootDir,
				s.context.AppConfig().Ssm.SessionLogsRetentionDurationHours)
		}
		if s.context.AppConfig().Agent.ContainerMode {
			instanceId, _ = platform.TargetID()
		}
		msg, err := buildAgentTaskComplete(log, res, instanceId)
		if err != nil {
			log.Errorf("Cannot build AgentTaskComplete message %s", err)
			return
		}
		if msg != nil {
			err = s.controlChannel.SendMessage(log, msg, websocket.BinaryMessage)
			if err != nil {
				log.Errorf("Error sending reply message %v", err)
			}
		}
	}
}
func ( s * Session ) listenReply ( resultChan chan contracts . DocumentResult , instanceId string ) { log := s . context . Log ( ) log . Info ( " " ) for res := range resultChan { if res . LastPlugin != " " { log . Infof ( " " , res . LastPlugin ) } else { log . Infof ( " " , res . MessageID ) instanceID , _ := platform . InstanceID ( ) go docmanager . DeleteSessionOrchestrationDirectories ( log , instanceID , s . context . AppConfig ( ) . Agent . OrchestrationRootDir , s . context . AppConfig ( ) . Ssm . SessionLogsRetentionDurationHours ) } if s . context . AppConfig ( ) . Agent . ContainerMode { instanceId , _ = platform . TargetID ( ) } msg , err := buildAgentTaskComplete ( log , res , instanceId ) if err != nil { log . Errorf ( " " , err ) return } if msg != nil { err = s . controlChannel . SendMessage ( log , msg , websocket . BinaryMessage ) if err != nil { log . Errorf ( " " , err ) } } } }
listenReply listens document result of session execution.
listenReply listens document result of session execution .
//processor guarantees to close this channel upon stop //Deleting Old Log Files // For last document level result, no need to send reply because there will be only one plugin for shell plugin case.