-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathwall_display.go
63 lines (55 loc) · 1.8 KB
/
wall_display.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2023 Team 254. All Rights Reserved.
// Author: [email protected] (Patrick Fairbank)
//
// Web handlers for a display that can be shown on a screen supplemental to one with the audience display overlay.
package web
import (
"github.com/Team254/cheesy-arena/game"
"github.com/Team254/cheesy-arena/model"
"github.com/Team254/cheesy-arena/websocket"
"net/http"
)
// Renders the audience display to be chroma keyed over the video feed.
func (web *Web) wallDisplayHandler(w http.ResponseWriter, r *http.Request) {
if !web.enforceDisplayConfiguration(w, r, map[string]string{
"background": "#000",
"reversed": "false",
"topSpacingPx": "0",
"zoomFactor": "1",
}) {
return
}
template, err := web.parseFiles("templates/wall_display.html")
if err != nil {
handleWebErr(w, err)
return
}
data := struct {
*model.EventSettings
MatchSounds []*game.MatchSound
}{web.arena.EventSettings, game.MatchSounds}
err = template.ExecuteTemplate(w, "wall_display.html", data)
if err != nil {
handleWebErr(w, err)
return
}
}
// The websocket endpoint for the audience display client to receive status updates.
func (web *Web) wallDisplayWebsocketHandler(w http.ResponseWriter, r *http.Request) {
display, err := web.registerDisplay(r)
if err != nil {
handleWebErr(w, err)
return
}
defer web.arena.MarkDisplayDisconnected(display.DisplayConfiguration.Id)
ws, err := websocket.NewWebsocket(w, r)
if err != nil {
handleWebErr(w, err)
return
}
defer ws.Close()
// Subscribe the websocket to the notifiers whose messages will be passed on to the client.
ws.HandleNotifiers(display.Notifier, web.arena.MatchTimingNotifier, web.arena.AudienceDisplayModeNotifier,
web.arena.MatchLoadNotifier, web.arena.MatchTimeNotifier, web.arena.RealtimeScoreNotifier,
web.arena.ReloadDisplaysNotifier)
}