MCPcopy Create free account
hub / github.com/DNAProject/DNA / checkSessionsTimeout

Method checkSessionsTimeout

http/websocket/websocket/server.go:229–252  ·  view source on GitHub ↗

check sessions timeout,if expire close the session

(done chan bool)

Source from the content-addressed store, hash-verified

227
228//check sessions timeout,if expire close the session
229func (self *WsServer) checkSessionsTimeout(done chan bool) {
230 ticker := time.NewTicker(time.Second * 10)
231 defer ticker.Stop()
232 for {
233 select {
234 case <-ticker.C:
235 var closeList []*session.Session
236 self.SessionList.ForEachSession(func(v *session.Session) {
237 if v.SessionTimeoverCheck() {
238 resp := rest.ResponsePack(Err.SESSION_EXPIRED)
239 v.Send(marshalResp(resp))
240 closeList = append(closeList, v)
241 }
242 })
243 for _, s := range closeList {
244 self.SessionList.CloseSession(s)
245 }
246
247 case <-done:
248 return
249 }
250 }
251
252}
253
254func (self *WsServer) webSocketHandler(w http.ResponseWriter, r *http.Request) {
255 wsConn, err := self.Upgrader.Upgrade(w, r, nil)

Callers 1

StartMethod · 0.95

Calls 7

ResponsePackFunction · 0.92
marshalRespFunction · 0.85
ForEachSessionMethod · 0.80
SessionTimeoverCheckMethod · 0.80
CloseSessionMethod · 0.80
StopMethod · 0.65
SendMethod · 0.65

Tested by

no test coverage detected