4 "code.octet-stream.net/broadcaster/internal/protocol"
6 "golang.org/x/net/websocket"
10 type CommandRouter
struct {
12 conns
map[int]*websocket
.Conn
15 var commandRouter CommandRouter
17 func InitCommandRouter() {
18 commandRouter
.conns
= make(map[int]*websocket
.Conn
)
21 func (c
*CommandRouter
) AddWebsocket(radioId
int, ws
*websocket
.Conn
) {
23 defer c
.connsMutex
.Unlock()
27 func (c
*CommandRouter
) RemoveWebsocket(ws
*websocket
.Conn
) {
29 defer c
.connsMutex
.Unlock()
31 for k
, v
:= range c
.conns
{
42 func (c
*CommandRouter
) Stop(radioId
int) {
44 defer c
.connsMutex
.Unlock()
45 ws
:= c
.conns
[radioId
]
47 stop
:= protocol
.StopMessage
{
50 msg
, _
:= json
.Marshal(stop
)