34 lines
657 B
Go
34 lines
657 B
Go
package socket
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/gorilla/websocket"
|
|
)
|
|
|
|
var displays = make(map[*websocket.Conn]bool)
|
|
|
|
func onNewDisplay(who *websocket.Conn) {
|
|
displays[who] = true
|
|
|
|
for _, conn := range onlineStaff {
|
|
if conn.Table == -1 {
|
|
continue
|
|
}
|
|
who.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf("status %d %d %d", conn.Table, conn.Status, conn.CurrentTicket)))
|
|
}
|
|
}
|
|
|
|
func onDisplayMessage(who *websocket.Conn, msg string) {
|
|
}
|
|
|
|
func onDisplayDisconnect(who *websocket.Conn) {
|
|
delete(displays, who)
|
|
}
|
|
|
|
func sendDisplayMessage(msg string) {
|
|
for display := range displays {
|
|
display.WriteMessage(websocket.TextMessage, []byte(msg))
|
|
}
|
|
}
|