lineproto

package
v0.10.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

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 LineReader interface {
	ReadLine() ([]byte, error)
}

type LineWriter added in v0.10.4

type LineWriter interface {
	WriteLine(data []byte) error
	Flush() error
}

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 NewReader

func NewReader(r io.Reader, delim byte) *Reader

NewReader allocates a Reader.

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) Close added in v0.10.0

func (r *Reader) Close() error

Close the reader and free associated resources.

func (*Reader) EnableZlib added in v0.5.1

func (r *Reader) EnableZlib() error

EnableZlib activates zlib inflating.

func (*Reader) OnLine

func (r *Reader) OnLine(fnc func(line []byte) (bool, error))

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

func (r *Reader) Read(buf []byte) (int, error)

Read reads a byte slice, inflates it if zlib is active, and puts the result into buf.

func (*Reader) ReadLine

func (r *Reader) ReadLine() ([]byte, error)

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

func (r *Reader) SetMaxLine(sz int)

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 NewWriter

func NewWriter(w io.Writer) *Writer

func NewWriterSize added in v0.7.3

func NewWriterSize(w io.Writer, buf int) *Writer

func (*Writer) Close added in v0.10.0

func (w *Writer) Close() error

Close flushes the writer and frees its resources. It won't close the underlying writer.

func (*Writer) DisableZlib added in v0.5.1

func (w *Writer) DisableZlib() error

DisableZlib deactivates zlib deflating.

func (*Writer) EnableZlib added in v0.5.1

func (w *Writer) EnableZlib() error

EnableZlib activates zlib deflating.

func (*Writer) EnableZlibLevel added in v0.8.1

func (w *Writer) EnableZlibLevel(lvl int) error

EnableZlib activates zlib deflating with a given compression level.

func (*Writer) Err

func (w *Writer) Err() error

Err returns the last encountered error.

func (*Writer) Flush added in v0.3.0

func (w *Writer) Flush() error

Flush forces all buffered writes to be flushed.

func (*Writer) OnLine added in v0.2.1

func (w *Writer) OnLine(fnc func(line []byte) (bool, error))

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.

func (*Writer) Write added in v0.10.0

func (w *Writer) Write(p []byte) (int, error)

Write the data to the connection. It will flush any remaining buffer and will bypass buffering for this call.

func (*Writer) WriteLine

func (w *Writer) WriteLine(data []byte) error

WriteLine writes a single protocol message.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL