Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBusy = errors.New("connection is busy")
ErrBusy is the error returned when concurrent requests for sending a message are made.
var ErrClosed = net.ErrClosed
ErrClosed is the error returned by an I/O call on a network connection that has already been closed, or that is closed by another goroutine before the I/O is completed.
var ErrIgnore = errors.New("ignore response")
ErrIgnore is the error used by response handler callbacks when a given message needs to be ignored.
var ErrNotRunning = errors.New("receiver not running")
ErrNotRunning is the error returned when the websocket receiver goroutine is no longer running and no specific error is available.
Functions ¶
This section is empty.
Types ¶
type Option ¶ added in v0.3.0
type Option func(*transport)
Option is the type of options for transports.
func WithLogFunc ¶ added in v0.3.0
WithLogFunc supplies a logging function to the transport. Received and sent messages are written as log messages.
type ResponseHandlerFunc ¶
ResponseHandlerFunc is the prototype for response handler callbacks.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is a wrapper for a LuxWS websocket connection.
func Dial ¶
Dial connects to a LuxWS server. The address must have the format "<host>:<port>" (see net.JoinHostPort). Use the context to establish a timeout.
func (Transport) Close ¶
func (t Transport) Close() error
Close immediately closes the underlying network connection. Any blocked read or write operations will be unblocked and return errors.
func (Transport) RemoteAddr ¶
RemoteAddr returns the remote network address.
func (Transport) RoundTrip ¶
func (t Transport) RoundTrip(ctx context.Context, req string, fn ResponseHandlerFunc) error
RoundTrip sends a request as a single message. All incoming messages are passed to the given handler function. If a response message is deemed an acceptable response the handler must return nil. If the message is not acceptable, but not an error, ErrIgnore can be returned by the handler. In all other cases an error must be returned.