Artifact 4d69f9edd220fdd98a27938b0733079f88e09b5342b62534443bdc7ccd50cb4c:
- File
leaf/wsdialer/dialer.go
— part of check-in
[eda7960b81]
at
2026-04-23 19:23:42
on branch trunk
— rename module to github.com/danmestas/EdgeSync
Fix the case-sensitive module path to match the actual GitHub repo URL (danmestas/EdgeSync). Remove tracked leaf/leaf binary and ignore .claude/skills/ scratchpad dirs. (user: [email protected], size: 772) [annotate] [blame] [check-ins using] [more...]
//go:build js package wsdialer import ( "fmt" "net" ) // WSDialer implements nats.CustomDialer using the browser's WebSocket API. // The URL field is the ws:// address of the NATS server's WebSocket port. // // Usage: // // nats.Connect(url, nats.SetCustomDialer(&wsdialer.WSDialer{URL: "ws://localhost:8080"})) type WSDialer struct { URL string } // Dial creates a new WebSocket connection. The network and address parameters // are ignored — the dialer always connects to the configured URL. func (d *WSDialer) Dial(network, address string) (net.Conn, error) { if d.URL == "" { panic("wsdialer: URL must not be empty") } conn := newWSConn(d.URL) if err := conn.waitOpen(); err != nil { return nil, fmt.Errorf("wsdialer: %w", err) } return conn, nil }