47fac22230
- .claude/CLAUDE.md - .claude/commands/subagentes.md - .claude/rules/INDEX.md - .mcp.json - bash/functions/cybersecurity/analyze_dns.md - bash/functions/cybersecurity/audit_http_headers.md - bash/functions/cybersecurity/audit_ssh_config.md - bash/functions/cybersecurity/check_firewall.md - bash/functions/cybersecurity/detect_suspicious_users.md - bash/functions/cybersecurity/encrypt_file.md - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1.8 KiB
1.8 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ws_send | function | go | infra | 1.0.0 | impure | func WSSend(client *WSClient, msg []byte) error | Envia bytes al canal Send de un cliente WebSocket 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 del hub usar WSBroadcast en su lugar. |
|
|
false | error_go_core |
|
|
error si el canal Send esta lleno (cliente lento) o cerrado (cliente desconectado). Nil si el mensaje se encolo correctamente. | true |
|
functions/infra/ws_test.go | functions/infra/ws_send.go |
Ejemplo
// Enviar mensaje a un cliente especifico (unicast)
target := findClientByID(hub, "user-42")
err := WSSend(target, []byte(`{"type":"notification","text":"hola"}`))
if err != nil {
log.Printf("send failed: %v", err)
}
Notas
Funcion no bloqueante: si el cliente no consume su canal Send, este se llena y la funcion retorna error inmediatamente en vez de bloquear al emisor. Esto previene que un cliente lento bloquee a otros productores.
El mensaje se encola en client.Send — la goroutine writePump del cliente lo escribira al websocket.Conn. No hay garantia de orden estricto entre llamadas concurrentes a WSSend sobre el mismo cliente.