transport

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package transport

Package transport

Package transport

Index

Constants

View Source
const (
	MagicCode         byte = 0x6f
	HeaderFixedLength      = 16
)
View Source
const (
	NextFlag byte = 1 << 3
	BinFlag  byte = 1 << 2
	RpcFlag  byte = 1 << 1
	AckFlag  byte = 1
)
View Source
const (
	None byte = iota
	Stream
	Open
	Close
)

Variables

This section is empty.

Functions

func ClientNegotiate

func ClientNegotiate(c io.ReadWriter, host string, credential string) (peer string, id string, err error)

func ServerNegotiate

func ServerNegotiate(c io.ReadWriter, host string, id string, validator func(credential string) error) (peer string, err error)

Types

type Frame

type Frame struct {
	Magic    byte
	Flag     byte
	Opcode   byte
	Reserved byte
	CheckSum uint32
	Group    uint16
	Index    uint16
	Length   uint32
	Payload  []byte
}

func NewFrame

func NewFrame(data []byte) *Frame

func (*Frame) Decode

func (f *Frame) Decode(data []byte) error

func (*Frame) DecodeHeader

func (f *Frame) DecodeHeader(data []byte) error

func (*Frame) Encode

func (f *Frame) Encode() []byte

func (*Frame) HasNext

func (f *Frame) HasNext() bool

func (*Frame) SetNext

func (f *Frame) SetNext()

type Transport

type Transport interface {
	Read() (*Frame, error)
	Write(*Frame) error
	Close() error
}

func New

func NewWebSocket

func NewWebSocket(c *websocket.Conn) Transport

Jump to

Keyboard shortcuts

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