transport

package
v1.6.1 Latest Latest
Warning

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

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

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

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

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() (frame.Type, packet.Type, io.ReadCloser, error)
}

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

type FrameWriter

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

FrameWriter writes a frame. It need 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

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