2018-06-30 16:20:54 +02:00
|
|
|
package websocket
|
|
|
|
|
|
|
|
import (
|
2018-07-26 14:14:23 +02:00
|
|
|
wsLib "dev.sum7.eu/genofire/golang-lib/websocket"
|
2018-06-30 16:20:54 +02:00
|
|
|
|
|
|
|
yanicRuntime "github.com/FreifunkBremen/yanic/runtime"
|
|
|
|
|
|
|
|
"github.com/FreifunkBremen/freifunkmanager/runtime"
|
|
|
|
)
|
|
|
|
|
2018-08-10 13:46:18 +02:00
|
|
|
func (ws *WebsocketServer) SendNode(node *runtime.Node) {
|
|
|
|
ws.ws.SendAll(&wsLib.Message{Subject: MessageTypeNode, Body: node})
|
2018-06-30 16:20:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (ws *WebsocketServer) SendStats(data *yanicRuntime.GlobalStats) {
|
|
|
|
ws.ws.SendAll(&wsLib.Message{Subject: MessageTypeStats, Body: data})
|
|
|
|
}
|
2018-08-24 23:44:26 +02:00
|
|
|
func (ws *WebsocketServer) SendPing(data interface{}) {
|
|
|
|
var sessions []*Session
|
|
|
|
msg := &wsLib.Message{Subject: MessageTypePing, Body: data}
|
|
|
|
|
|
|
|
ws.db.Find(&sessions)
|
|
|
|
for _, session := range sessions {
|
|
|
|
if session.Ping {
|
|
|
|
ws.ws.SendSession(session.SessionID, msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|