Documentation ¶
Overview ¶
Package jsonbuffer implements a stream protocol using JSON blobs as segments in the buffer, with a type and envelope.
Each message is sent as JSON (see the Message struct) and contains a type and payload. The type determines how the payload is handled; but arguably what happens as a result of that belongs to the client.
There is also a javascript client for this in the ci-ui repository.
Index ¶
Constants ¶
const ( // TypeMessage is a message and the payload is the message we're trying to send. TypeMessage = "message" // TypeError is an error and the payload is the error text. TypeError = "error" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Wrapper ¶
Wrapper is a wrapper for io.Reader that lets us power it via protocol through our client.
func NewWrapper ¶
func NewWrapper(rw io.ReadWriter) *Wrapper
NewWrapper creates a Wrapper from a pre-established connection.
func (*Wrapper) Read ¶
Read conforms to the io.Reader interface. If it cannot fill buf with the payload, it will keep the buffer for the next read call.
func (*Wrapper) Recv ¶
Recv reads a single message from the reader and returns it. If the type is message, it returns the payload, otherwise if it hits EOF it will return ErrEOF; on any error return it returns the error.
func (*Wrapper) Send ¶
Send sends a message by writing through the Wrapper. The outgoing message will be of type websocket.TypeMessage.