Documentation
¶
Index ¶
- Constants
- func Bind(sr SendRecver, read SocketReader) xws.Handler
- func BindRead(r RecvCloser) xws.Handler
- func Check(config *xws.Config, req *http.Request) error
- func DefaultRead(c *xws.Conn) ([]byte, bool, error)
- type Binder
- type Handshaker
- type HangupRecver
- type HangupSender
- type MessageError
- type RecvCloser
- type Recver
- type SendRecver
- type Sender
- type SocketReader
Constants ¶
const DefaultBuffer = 64
DefaultBuffer is the size of the DefaultRead buffer.
Variables ¶
This section is empty.
Functions ¶
func Bind ¶
func Bind(sr SendRecver, read SocketReader) xws.Handler
Bind routes messages and errors between a SendRecver and a websocket connection.
func BindRead ¶
func BindRead(r RecvCloser) xws.Handler
BindRead receives messages from a Recver and writes them to the Conn. It should be used in place of Bind for one-way messaging from the backend to the websocket client. It reads and discards all bytes sent on the Conn, and closes if Conn.Read returns io.EOF.
Types ¶
type Handshaker ¶
Handshaker is a function that checks an HTTP request for websockets.
type HangupRecver ¶
HangupRecver is a type which is hung up when it sends its response, and upon being hung up, will close the River socket used in its Recv.
func MakeHangupRecver ¶
func MakeHangupRecver(rsp river.Responder, r RecvCloser) HangupRecver
MakeHangupRecver makes a new HangupRecver which will close its Recver socket when it responds to a hangup Survey.
func (HangupRecver) Recver ¶
func (h HangupRecver) Recver() RecvCloser
Recver returns the HangupRecver's Recv socket, which is closed when the HangupRecver replies to a hangup survey.
func (HangupRecver) Send ¶
func (h HangupRecver) Send(bs []byte) error
Send implements Responder.Send on HangupRecver, closing its signal channel and calling Send on the underlying Responder. Make sure this is only called once!
type HangupSender ¶
HangupSender is a Responder river which closes its signal channel after Sending.
func MakeHangup ¶
func MakeHangup(r river.Responder, sr SocketReader) HangupSender
MakeHangup creates a new HangupSender from the given river.Responder and SocketReader. If the SocketReader is nil, DefaultReader will be used.
func (HangupSender) Read ¶
Read is a SocketReader which returns io.EOF when the HangupSender has Sent and closes the Conn.
TODO: Tighten this up a lot!
func (HangupSender) Send ¶
func (h HangupSender) Send(msg []byte) error
Send implements river.Responder.Send on HangupSender, closing its signal channel and calling Send on the underlying Responder. Make sure this is only called once.
type MessageError ¶
type MessageError struct{ Error error }
MessageError is a JSON-serializable error message.
func (MessageError) MarshalJSON ¶
func (m MessageError) MarshalJSON() ([]byte, error)
MarshalJSON implements JSON.Marshaler on MessageError.