lineproto

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: May 1, 2019 License: BSD-3-Clause Imports: 7 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

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) 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.

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) 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) Err

func (w *Writer) Err() 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) 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