Documentation ¶
Index ¶
- type ErrProtocolViolation
- type LineReader
- type LineWriter
- type Reader
- func (r *Reader) Binary(sz uint64) (io.ReadCloser, error)
- func (r *Reader) Close() error
- func (r *Reader) EnableZlib() error
- func (r *Reader) OnLine(fnc func(line []byte) (bool, error))
- func (r *Reader) Read(buf []byte) (int, error)
- func (r *Reader) ReadLine() ([]byte, error)
- func (r *Reader) SetMaxLine(sz int)
- type Writer
- func (w *Writer) Close() error
- func (w *Writer) DisableZlib() error
- func (w *Writer) EnableZlib() error
- func (w *Writer) EnableZlibLevel(lvl int) error
- func (w *Writer) Err() error
- func (w *Writer) Flush() error
- func (w *Writer) OnLine(fnc func(line []byte) (bool, error))
- func (w *Writer) Write(p []byte) (int, error)
- func (w *Writer) WriteLine(data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrProtocolViolation ¶
type ErrProtocolViolation struct {
Err error
}
func (*ErrProtocolViolation) Error ¶
func (e *ErrProtocolViolation) Error() string
func (*ErrProtocolViolation) Unwrap ¶ added in v0.10.4
func (e *ErrProtocolViolation) Unwrap() error
type LineReader ¶ added in v0.10.4
type LineWriter ¶ added in v0.10.4
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is a line reader that supports the zlib on/off switching procedure required by hub-to-client and client-to-client connections.
func (*Reader) Binary ¶ added in v0.10.0
func (r *Reader) Binary(sz uint64) (io.ReadCloser, error)
Binary returns a binary reader locked to the given amount of bytes. Caller must close the reader. Reader will automatically drain any unread bytes.
func (*Reader) EnableZlib ¶ added in v0.5.1
EnableZlib activates zlib inflating.
func (*Reader) OnLine ¶
OnLine registers a hook that is called each time a raw protocol line is read from the connection. The buffer will contain a delimiter and is in the connection encoding. The function may return (false, nil) to ignore the message.
This method is not concurrent-safe.
func (*Reader) Read ¶ added in v0.4.2
Read reads a byte slice, inflates it if zlib is active, and puts the result into buf.
func (*Reader) ReadLine ¶
ReadLine reads a single raw message until the delimiter. The returned buffer contains a delimiter and is in the connection encoding. The buffer is only valid until the next call to Read or ReadLine.
func (*Reader) SetMaxLine ¶
SetMaxLine sets the max allowed protocol line length. Values <= 0 mean no limit.
type Writer ¶
type Writer struct { // Timeout is a callback to setup timeout on each write. Timeout func(enable bool) error // contains filtered or unexported fields }
Writer is not safe for concurrent use.
func (*Writer) Close ¶ added in v0.10.0
Close flushes the writer and frees its resources. It won't close the underlying writer.
func (*Writer) DisableZlib ¶ added in v0.5.1
DisableZlib deactivates zlib deflating.
func (*Writer) EnableZlib ¶ added in v0.5.1
EnableZlib activates zlib deflating.
func (*Writer) EnableZlibLevel ¶ added in v0.8.1
EnableZlib activates zlib deflating with a given compression level.
func (*Writer) OnLine ¶ added in v0.2.1
OnLine registers a hook that is called each time a raw protocol message is written. The function may return (false, nil) to skip writing the message.
This method is not concurrent-safe.