MCPcopy
hub / github.com/wavetermdev/waveterm / keepAliveMonitor

Method keepAliveMonitor

pkg/remote/conncontroller/connmonitor.go:159–192  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

157}
158
159func (cm *ConnMonitor) keepAliveMonitor() {
160 defer func() {
161 panichandler.PanicHandler("conncontroller:keepAliveMonitor", recover())
162 }()
163 ticker := time.NewTicker(5 * time.Second)
164 defer ticker.Stop()
165
166 for {
167 // check if our client is still the active one
168 if cm.Conn.GetClient() != cm.Client {
169 return
170 }
171
172 select {
173 case <-ticker.C:
174 cm.checkConnection()
175
176 case inputTime := <-cm.inputNotifyCh:
177 select {
178 case <-time.After(1 * time.Second):
179 if cm.LastActivityTime.Load() >= inputTime {
180 break
181 }
182 cm.setConnHealthStatus(ConnHealthStatus_Degraded)
183 cm.checkConnection()
184 case <-cm.ctx.Done():
185 return
186 }
187
188 case <-cm.ctx.Done():
189 return
190 }
191 }
192}
193
194func (cm *ConnMonitor) Close() {
195 if cm.cancelFunc != nil {

Callers 1

MakeConnMonitorFunction · 0.95

Calls 5

checkConnectionMethod · 0.95
setConnHealthStatusMethod · 0.95
PanicHandlerFunction · 0.92
StopMethod · 0.65
GetClientMethod · 0.45

Tested by

no test coverage detected