wsjson
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeDecoder¶
type Decoder[Tany] struct {// contains filtered or unexported fields}
funcNewDecoder¶
func NewDecoder[Tany](conn *websocket.Conn, typwebsocket.MessageType, loggerslog.Logger) *Decoder[T]
NewDecoder creates a JSON-over-websocket decoder for type T, which must be deserializable fromJSON.
func (*Decoder[T])Chan¶
func (d *Decoder[T]) Chan() <-chan T
Chan returns a `chan` that you can read incoming messages from. The returned`chan` will be closed when the WebSocket connection is closed. If there is anerror reading from the WebSocket or decoding a value the WebSocket will beclosed.
Safety: Chan must only be called once. Successive calls will panic.
typeEncoder¶
type Encoder[Tany] struct {// contains filtered or unexported fields}
funcNewEncoder¶
NewEncoder creates a JSON-over websocket encoder for the type T, which must be JSON-serializable.You may then call Encode() to send objects over the websocket. Creating an Encoder closes thewebsocket for reading, turning it into a unidirectional write stream of JSON-encoded objects.
typeStream¶added inv2.22.0
Stream is a two-way messaging interface over a WebSocket connection.
func (*Stream[R, W])Chan¶added inv2.22.0
func (s *Stream[R, W]) Chan() <-chan R
Chan returns a `chan` that you can read incoming messages from. The returned`chan` will be closed when the WebSocket connection is closed. If there is anerror reading from the WebSocket or decoding a value the WebSocket will beclosed.
Safety: Chan must only be called once. Successive calls will panic.