base

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: May 2, 2021 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpErr

func OpErr(url, op string, err error) error

OpErr makes an *OpError

func Timestamp

func Timestamp() string

Timestamp returns a string based on different nano time.

func TimestampFromClock added in v1.4.5

func TimestampFromClock(c clock) string

Types

type Conn

type Conn interface {
	FrameReader
	FrameWriter
	io.Closer
	URL() url.URL
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
	RemoteHeader() http.Header
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
}

Conn is a connection.

type ConnParameters

type ConnParameters struct {
	PingInterval time.Duration
	PingTimeout  time.Duration
	SID          string
	Upgrades     []string
}

ConnParameters is connection parameter of server.

func ReadConnParameters

func ReadConnParameters(r io.Reader) (ConnParameters, error)

ReadConnParameters reads ConnParameters from r.

func (ConnParameters) WriteTo

func (p ConnParameters) WriteTo(w io.Writer) (int64, error)

WriteTo writes to w with json format.

type FrameReader

type FrameReader interface {
	NextReader() (FrameType, PacketType, io.ReadCloser, error)
}

FrameReader reads a frame. It need be closed before next reading.

type FrameType

type FrameType byte

FrameType is the type of frames.

const (
	// FrameString identifies a string frame.
	FrameString FrameType = iota
	// FrameBinary identifies a binary frame.
	FrameBinary
)

func ByteToFrameType

func ByteToFrameType(b byte) FrameType

ByteToFrameType converts a byte to FrameType.

func (FrameType) Byte

func (t FrameType) Byte() byte

Byte returns type in byte.

type FrameWriter

type FrameWriter interface {
	NextWriter(ft FrameType, pt PacketType) (io.WriteCloser, error)
}

FrameWriter writes a frame. It need be closed before next writing.

type OpError

type OpError struct {
	URL string
	Op  string
	Err error
}

OpError is the error type usually returned by functions in the transport package.

func (*OpError) Error

func (e *OpError) Error() string

func (*OpError) Temporary

func (e *OpError) Temporary() bool

Temporary returns true if the error is temporary.

func (*OpError) Timeout

func (e *OpError) Timeout() bool

Timeout returns true if the error is a timeout.

type PacketType

type PacketType int

PacketType is the type of packet

const (
	// OPEN is sent from the server when a new transport is opened (recheck).
	OPEN PacketType = iota
	// CLOSE is request the close of this transport but does not shutdown the
	// connection itself.
	CLOSE
	// PING is sent by the client. Server should answer with a pong packet
	// containing the same data.
	PING
	// PONG is sent by the server to respond to ping packets.
	PONG
	// MESSAGE is actual message, client and server should call their callbacks
	// with the data.
	MESSAGE
	// UPGRADE is sent before engine.io switches a transport to test if server
	// and client can communicate over this transport. If this test succeed,
	// the client sends an upgrade packets which requests the server to flush
	// its cache on the old transport and switch to the new transport.
	UPGRADE
	// NOOP is a noop packet. Used primarily to force a poll cycle when an
	// incoming websocket connection is received.
	NOOP
)

func ByteToPacketType

func ByteToPacketType(b byte, typ FrameType) PacketType

ByteToPacketType converts a byte to PacketType.

func (PacketType) BinaryByte

func (id PacketType) BinaryByte() byte

BinaryByte converts a PacketType to byte in binary.

func (PacketType) String

func (id PacketType) String() string

func (PacketType) StringByte

func (id PacketType) StringByte() byte

StringByte converts a PacketType to byte in string.

Jump to

Keyboard shortcuts

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