feat: WebSocket upgrader, hub, send, broadcast, handler con tests (issue 0011 fase 3-4)
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package infra
|
||||
|
||||
import "fmt"
|
||||
|
||||
// WSBroadcast envia bytes al canal Broadcast del hub para entregar el mensaje
|
||||
// a todos los clientes conectados. La entrega real la hace el loop Run() del hub.
|
||||
// Bloqueante hasta que el canal Broadcast tenga espacio (capacidad 256 por defecto).
|
||||
func WSBroadcast(hub *WSHub, msg []byte) error {
|
||||
if hub == nil {
|
||||
return fmt.Errorf("ws broadcast: hub is nil")
|
||||
}
|
||||
hub.Broadcast <- msg
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user