wsutil

package
v0.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultPingInterval = 30 * time.Second
	DefaultPingTimeout  = 10 * time.Second
)

Variables

This section is empty.

Functions

func Bridge

func Bridge(conn *websocket.Conn, messenger model.Messenger, opts ...Option)

Bridge relays JSON both ways between conn and messenger, blocking until the connection ends; it closes the Messenger on return, but conn stays the caller's to close.

func Close

func Close(ctx context.Context, conn *websocket.Conn, err error) error

Close closes conn per the handler's err (nil, peer close, EOF, ctx done: no failure); it returns err only for an otherwise unexplained error, sent as an internal error.

Types

type Option

type Option func(*bridge)

func WithLogger

func WithLogger(logger log.Logger) Option

func WithPing

func WithPing(interval, timeout time.Duration) Option

WithPing: interval 0 disables pings; a pong missing past timeout tears the session down.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL