MCPcopy
hub / github.com/IceWhaleTech/CasaOS / SendMeg

Function SendMeg

service/notify.go:283–324  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

281}
282
283func SendMeg() {
284 // for {
285 // mt, message, err := ws.ReadMessage()
286 // if err != nil {
287 // break
288 // }
289 // notify := model.NotifyMssage{}
290 // json2.Unmarshal(message, &notify)
291 // if notify.Type == "read" {
292 // service.MyService.Notify().MarkRead(notify.Data, types.NOTIFY_READ)
293 // }
294 // if notify.Type == "app" {
295 // go func(ws *websocket.Conn) {
296
297 for {
298 list := MyService.Notify().GetList(types.NOTIFY_APP)
299 json, _ := json2.Marshal(list)
300
301 if len(list) > 0 {
302 var temp []*websocket.Conn
303 for _, v := range WebSocketConns {
304
305 err := v.WriteMessage(1, json)
306 if err == nil {
307 temp = append(temp, v)
308 }
309 }
310 WebSocketConns = temp
311 for _, v := range list {
312 MyService.Notify().MarkRead(v.Id, types.NOTIFY_READ)
313 }
314 }
315
316 if len(WebSocketConns) == 0 {
317 SocketRun = false
318 }
319 time.Sleep(time.Second * 2)
320 }
321 // }(ws)
322 // }
323 // }
324}
325
326// func (i notifyServer) SendText(m model.AppNotify) {
327// list := []model.AppNotify{}

Callers 1

NotifyWSFunction · 0.92

Calls 3

GetListMethod · 0.65
NotifyMethod · 0.65
MarkReadMethod · 0.65

Tested by

no test coverage detected