netxfer

package
v0.0.0-...-7551c24 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpStart  = Op(0)
	OpAccept = Op(1)
	OpData   = Op(2)
	OpAck    = Op(3)
	OpDone   = Op(4)
	OpCancel = Op(5)
	OpAbort  = Op(6)
)
View Source
const (
	ErrClosed      = Error(1)
	ErrSendTimeout = Error(2)
	ErrRecvTimeout = Error(3)
)

Variables

This section is empty.

Functions

func Encode

func Encode(data []byte, m Msg) (int, error)

func EncodeSize

func EncodeSize(m Msg) int

Types

type AbortFunc

type AbortFunc func(reason Error)

type Action

type Action byte

type Chunk

type Chunk uint16

type Conn

type Conn interface {
	comparable
	SendReliable(m netmsg.Message) error
	SendUnreliable(m netmsg.Message) error
}

type Data

type Data struct {
	Action Action
	Type   string
	Data   []byte
}

type DoneFunc

type DoneFunc func()

type Error

type Error byte

func (Error) Error

func (e Error) Error() string

type Msg

type Msg interface {
	XferOp() Op
	binenc.Encoded
}

func Decode

func Decode(data []byte) (Msg, int, error)

type MsgAbort

type MsgAbort struct {
	RecvID RecvID
	Reason Error
}

func (*MsgAbort) Decode

func (m *MsgAbort) Decode(data []byte) (int, error)

func (*MsgAbort) Encode

func (m *MsgAbort) Encode(data []byte) (int, error)

func (*MsgAbort) EncodeSize

func (*MsgAbort) EncodeSize() int

func (*MsgAbort) XferOp

func (*MsgAbort) XferOp() Op

type MsgAccept

type MsgAccept struct {
	RecvID RecvID // use this to send data
	SendID SendID // accepted send stream
}

func (*MsgAccept) Decode

func (m *MsgAccept) Decode(data []byte) (int, error)

func (*MsgAccept) Encode

func (m *MsgAccept) Encode(data []byte) (int, error)

func (*MsgAccept) EncodeSize

func (*MsgAccept) EncodeSize() int

func (*MsgAccept) XferOp

func (*MsgAccept) XferOp() Op

type MsgAck

type MsgAck struct {
	RecvID RecvID
	Token  byte
	Chunk  Chunk
}

func (*MsgAck) Decode

func (m *MsgAck) Decode(data []byte) (int, error)

func (*MsgAck) Encode

func (m *MsgAck) Encode(data []byte) (int, error)

func (*MsgAck) EncodeSize

func (*MsgAck) EncodeSize() int

func (*MsgAck) XferOp

func (*MsgAck) XferOp() Op

type MsgCancel

type MsgCancel struct {
	RecvID RecvID
	Reason Error
}

func (*MsgCancel) Decode

func (m *MsgCancel) Decode(data []byte) (int, error)

func (*MsgCancel) Encode

func (m *MsgCancel) Encode(data []byte) (int, error)

func (*MsgCancel) EncodeSize

func (*MsgCancel) EncodeSize() int

func (*MsgCancel) XferOp

func (*MsgCancel) XferOp() Op

type MsgData

type MsgData struct {
	RecvID RecvID
	Token  byte
	Chunk  Chunk
	Data   []byte
}

func (*MsgData) Decode

func (m *MsgData) Decode(data []byte) (int, error)

func (*MsgData) Encode

func (m *MsgData) Encode(data []byte) (int, error)

func (*MsgData) EncodeSize

func (m *MsgData) EncodeSize() int

func (*MsgData) XferOp

func (*MsgData) XferOp() Op

type MsgDone

type MsgDone struct {
	RecvID RecvID
}

func (*MsgDone) Decode

func (m *MsgDone) Decode(data []byte) (int, error)

func (*MsgDone) Encode

func (m *MsgDone) Encode(data []byte) (int, error)

func (*MsgDone) EncodeSize

func (*MsgDone) EncodeSize() int

func (*MsgDone) XferOp

func (*MsgDone) XferOp() Op

type MsgStart

type MsgStart struct {
	Act    Action
	Unk1   byte
	Size   uint32
	Type   binenc.String
	SendID SendID
	Unk5   [3]byte
}

func (*MsgStart) Decode

func (m *MsgStart) Decode(data []byte) (int, error)

func (*MsgStart) Encode

func (m *MsgStart) Encode(data []byte) (int, error)

func (*MsgStart) EncodeSize

func (*MsgStart) EncodeSize() int

func (*MsgStart) XferOp

func (*MsgStart) XferOp() Op

type MsgXfer

type MsgXfer struct {
	Msg Msg
}

func (*MsgXfer) Decode

func (m *MsgXfer) Decode(data []byte) (int, error)

func (*MsgXfer) Encode

func (m *MsgXfer) Encode(data []byte) (int, error)

func (*MsgXfer) EncodeSize

func (m *MsgXfer) EncodeSize() int

func (*MsgXfer) NetOp

func (*MsgXfer) NetOp() netmsg.Op

type Op

type Op byte

type ReceiveFunc

type ReceiveFunc[C Conn] func(conn C, p Data)

type Receiver

type Receiver[C Conn] struct {
	// contains filtered or unexported fields
}

func (*Receiver[C]) Handle

func (x *Receiver[C]) Handle(conn C, ts time.Duration, m Msg)

func (*Receiver[C]) HandleCancel

func (x *Receiver[C]) HandleCancel(conn C, m *MsgCancel)

func (*Receiver[C]) HandleData

func (x *Receiver[C]) HandleData(conn C, ts time.Duration, m *MsgData)

func (*Receiver[C]) HandleStart

func (x *Receiver[C]) HandleStart(conn C, ts time.Duration, m *MsgStart)

func (*Receiver[C]) OnReceive

func (x *Receiver[C]) OnReceive(fnc ReceiveFunc[C])

func (*Receiver[C]) Reset

func (x *Receiver[C]) Reset(n int)

func (*Receiver[C]) Update

func (x *Receiver[C]) Update(ts time.Duration)

type RecvID

type RecvID byte

type SendID

type SendID byte

type Sender

type Sender[C Conn] struct {
	// contains filtered or unexported fields
}

func (*Sender[C]) Cancel

func (x *Sender[C]) Cancel(conn C, id SendID)

func (*Sender[C]) CancelAll

func (x *Sender[C]) CancelAll(conn C)

func (*Sender[C]) Handle

func (x *Sender[C]) Handle(conn C, ts time.Duration, m Msg)

func (*Sender[C]) HandleAbort

func (x *Sender[C]) HandleAbort(conn C, m *MsgAbort)

func (*Sender[C]) HandleAccept

func (x *Sender[C]) HandleAccept(conn C, m *MsgAccept)

func (*Sender[C]) HandleAck

func (x *Sender[C]) HandleAck(conn C, m *MsgAck)

func (*Sender[C]) HandleDone

func (x *Sender[C]) HandleDone(conn C, m *MsgDone)

func (*Sender[C]) Reset

func (x *Sender[C]) Reset(n int)

func (*Sender[C]) Send

func (x *Sender[C]) Send(ctx context.Context, conn C, p Data) error

func (*Sender[C]) StartSend

func (x *Sender[C]) StartSend(conn C, p Data, onDone DoneFunc, onAbort AbortFunc) (SendID, bool)

func (*Sender[C]) Update

func (x *Sender[C]) Update(ts time.Duration)

type State

type State[C Conn] struct {
	Sender[C]
	Receiver[C]
}

func (*State[C]) Handle

func (x *State[C]) Handle(conn C, ts time.Duration, m Msg)

func (*State[C]) Reset

func (x *State[C]) Reset(n int)

func (*State[C]) Update

func (x *State[C]) Update(ts time.Duration)

Jump to

Keyboard shortcuts

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