feat: WebSocket upgrader, hub, send, broadcast, handler con tests (issue 0011 fase 3-4)

This commit is contained in:
2026-04-18 17:29:37 +02:00
parent 637bc8fd34
commit e35ec39c10
11 changed files with 784 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
package infra
import "fmt"
// WSSend envia bytes al canal Send de un cliente especifico de forma no bloqueante.
// Si el canal esta lleno o el cliente desconectado, retorna error sin bloquear al emisor.
// Para broadcast a todos los clientes usar WSBroadcast.
func WSSend(client *WSClient, msg []byte) error {
if client == nil {
return fmt.Errorf("ws send: client is nil")
}
select {
case client.Send <- msg:
return nil
default:
return fmt.Errorf("ws send: client %s send channel full or closed", client.ID)
}
}