| 281 | } |
| 282 | |
| 283 | func SendMeg() { |
| 284 | // for { |
| 285 | // mt, message, err := ws.ReadMessage() |
| 286 | // if err != nil { |
| 287 | // break |
| 288 | // } |
| 289 | // notify := model.NotifyMssage{} |
| 290 | // json2.Unmarshal(message, ¬ify) |
| 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{} |