more symmetry. SetupHeartBeat froma agent to server now done in separate

call.
This commit is contained in:
Erik Brakkee 2024-08-19 19:46:39 +02:00
parent 9f90f9a2b8
commit 974b4b9ad0
2 changed files with 17 additions and 17 deletions

View File

@ -322,6 +322,7 @@ func main() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
comms.SetupHeartBeat(commChannel)
// initial check // initial check

View File

@ -68,8 +68,12 @@ func NewCommChannel(role Role, wsConn io.ReadWriteCloser) (CommChannel, error) {
} }
log.Println("Communication channel between agent and converge server established") log.Println("Communication channel between agent and converge server established")
// heartbeat return commChannel, nil
if role == Agent { }
// Communication from agent to server during the session.
func SetupHeartBeat(commChannel CommChannel) {
go func() { go func() {
for { for {
time.Sleep(10 * time.Second) time.Sleep(10 * time.Second)
@ -82,13 +86,8 @@ func NewCommChannel(role Role, wsConn io.ReadWriteCloser) (CommChannel, error) {
} }
} }
}() }()
}
return commChannel, nil
} }
// Sending an event to the other side
func ListenForAgentEvents(channel GOBChannel, func ListenForAgentEvents(channel GOBChannel,
agentInfo func(agent EnvironmentInfo), agentInfo func(agent EnvironmentInfo),
sessionInfo func(session SessionInfo), sessionInfo func(session SessionInfo),