Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewJSInterface ¶
NewJSInterface creates a JavaScript object wrapping the WebSocket connection. It exposes: send(string|Uint8Array), close(), and callback properties onmessage, onclose, onerror.
Callback properties may be set from the JS thread while the read loop goroutine reads them. In WASM this is safe because Go and JS share a single thread, but the design would need synchronization on multi-threaded runtimes.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn wraps a WebSocket connection over a NetBird TCP connection.
func Dial ¶
func Dial(ctx context.Context, client *netbird.Client, rawURL string, protocols []string) (*Conn, error)
Dial establishes a WebSocket connection to the given URL through the NetBird network. Optional protocols are sent via the Sec-WebSocket-Protocol header.
func (*Conn) Close ¶
Close sends a close frame with StatusNormalClosure and closes the underlying connection.
func (*Conn) ReadMessage ¶
ReadMessage reads the next WebSocket message, handling control frames automatically.
func (*Conn) WriteBinary ¶
WriteBinary sends a binary WebSocket message.