Fix issue with server not broadcasting
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
var upgrader = websocket.Upgrader{}
|
||||
var wsBroadcast = make(chan []byte, 100)
|
||||
var wsBroadcast = make(chan string, 128)
|
||||
|
||||
const TIMEOUT = 6
|
||||
const IDLE_TIMEOUT = TIMEOUT * time.Second
|
||||
@@ -90,6 +90,12 @@ func (ws *WSConnection) Open() {
|
||||
go ws.messageReader()
|
||||
go ws.messageSender()
|
||||
go ws.pinger()
|
||||
go func() {
|
||||
for {
|
||||
msg := <-wsBroadcast
|
||||
ws.WriteChan <- msg
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func wsHandler(responseWriter http.ResponseWriter, request *http.Request) {
|
||||
@@ -126,7 +132,7 @@ func handleDownload(responseWriter http.ResponseWriter, request *http.Request) {
|
||||
}
|
||||
|
||||
log.Printf("Received download request: %s", req.Link)
|
||||
wsBroadcast <- []byte(req.Link)
|
||||
wsBroadcast <- req.Link
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
Reference in New Issue
Block a user