transport

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: BSD-3-Clause Imports: 9 Imported by: 61

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidFrame = errors.New("invalid frame type")

ErrInvalidFrame is returned when writing invalid frame type.

Functions

This section is empty.

Types

type Conn added in v1.5.0

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 transport connection.

type ConnParameters added in v1.5.0

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

ConnParameters is connection parameter of server.

func ReadConnParameters added in v1.5.0

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

ReadConnParameters reads ConnParameters from r.

func (ConnParameters) WriteTo added in v1.5.0

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

WriteTo writes to w with json format.

type FrameReader added in v1.5.0

type FrameReader interface {
	NextReader() (frame.Type, packet.Type, io.ReadCloser, error)
}

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

type FrameWriter added in v1.5.0

type FrameWriter interface {
	NextWriter(ft frame.Type, pt packet.Type) (io.WriteCloser, error)
}

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

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is a manager of transports.

func NewManager

func NewManager(transports []Transport) *Manager

NewManager creates a new manager.

func (*Manager) Get

func (m *Manager) Get(name string) (Transport, bool)

Get returns the transport with given name.

func (*Manager) UpgradeFrom

func (m *Manager) UpgradeFrom(name string) []string

UpgradeFrom returns a name list of transports which can upgrade from given name.

type Transport

type Transport interface {
	Name() string
	Accept(w http.ResponseWriter, r *http.Request) (Conn, error)
	Dial(u *url.URL, requestHeader http.Header) (Conn, error)
}

Transport is a transport which can creates base.Conn

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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