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 ¶
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.
Click to show internal directories.
Click to hide internal directories.