Documentation
¶
Overview ¶
Package transport deals with packet-like connections between endpoints. It includes helpers to create them from sockets or as derived concepts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallServer ¶ added in v0.1.42
CallServer runs a new socket server with an internal simple keyed protocol. Invokes the handler for every new bidirectional call. This is designed to be similar-ish to WebTransport so we can use that one day.
Types ¶
type Transport ¶
type Transport interface {
// Read reads the next message available into the given target, e.g., by decoding.
Read(any) error
// Send sends the given message.
// This may block, or not, and may always return nil (e.g., message put into queue rather than sent directly).
Send(any) error
// Context returns a context which is Done when the underlying connection has closed.
Context() context.Context
}
func SocketJSON ¶
func SocketJSON(ctx context.Context, sock *websocket.Conn) (t Transport, cancel context.CancelCauseFunc)
SocketJSON wraps an open websocket.Conn, converting it to an untyped Transport that reads and writes JSON. It derives a new Context which is canceled only if a Read/Send operation fails, but which also closes the socket itself. If the cancel method is called with a websocket.CloseError, the socket is closed in that way.