more symmetry. SetupHeartBeat froma agent to server now done in separate
call.
This commit is contained in:
parent
9f90f9a2b8
commit
974b4b9ad0
@ -322,6 +322,7 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
comms.SetupHeartBeat(commChannel)
|
||||
|
||||
// initial check
|
||||
|
||||
|
@ -68,26 +68,25 @@ func NewCommChannel(role Role, wsConn io.ReadWriteCloser) (CommChannel, error) {
|
||||
}
|
||||
log.Println("Communication channel between agent and converge server established")
|
||||
|
||||
// heartbeat
|
||||
if role == Agent {
|
||||
go func() {
|
||||
for {
|
||||
time.Sleep(10 * time.Second)
|
||||
err := Send(commChannel.SideChannel,
|
||||
ConvergeMessage{
|
||||
Value: HeartBeat{},
|
||||
})
|
||||
if err != nil {
|
||||
log.Println("Sending heartbeat to server failed")
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
return commChannel, nil
|
||||
}
|
||||
|
||||
// Sending an event to the other side
|
||||
// Communication from agent to server during the session.
|
||||
|
||||
func SetupHeartBeat(commChannel CommChannel) {
|
||||
go func() {
|
||||
for {
|
||||
time.Sleep(10 * time.Second)
|
||||
err := Send(commChannel.SideChannel,
|
||||
ConvergeMessage{
|
||||
Value: HeartBeat{},
|
||||
})
|
||||
if err != nil {
|
||||
log.Println("Sending heartbeat to server failed")
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func ListenForAgentEvents(channel GOBChannel,
|
||||
agentInfo func(agent EnvironmentInfo),
|
||||
|
Loading…
Reference in New Issue
Block a user