Documentation ¶
Index ¶
- Constants
- type Buffer
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Copy() *Buffer
- func (b *Buffer) GetByte() (byte, error)
- func (b *Buffer) GetBytes(length int) ([]byte, error)
- func (b *Buffer) GetInt16() (int16, error)
- func (b *Buffer) GetInt32() (int32, error)
- func (b *Buffer) GetInt64() (int64, error)
- func (b *Buffer) GetInt8() (int8, error)
- func (b *Buffer) GetUint16() (uint16, error)
- func (b *Buffer) GetUint32() (uint32, error)
- func (b *Buffer) GetUint64() (uint64, error)
- func (b *Buffer) GetUint8() (uint8, error)
- func (b *Buffer) Len() int
- func (b *Buffer) Reset()
- func (b *Buffer) WriteByte(n byte)
- func (b *Buffer) WriteBytes(src []byte)
- func (b *Buffer) WriteBytesN(src []byte, length int)
- func (b *Buffer) WriteFloat32(n float32)
- func (b *Buffer) WriteFloat64(buf []byte, n float64)
- func (b *Buffer) WriteInt16(n int16)
- func (b *Buffer) WriteInt32(n int32)
- func (b *Buffer) WriteInt64(n int64)
- func (b *Buffer) WriteInt8(n int8)
- func (b *Buffer) WriteUint16(n uint16)
- func (b *Buffer) WriteUint32(n uint32)
- func (b *Buffer) WriteUint64(n uint64)
- func (b *Buffer) WriteUint8(n uint8)
- type PacketAck
- type PacketUDP
- type PlayerNetwork
- func (p *PlayerNetwork) AckBandwidth() float32
- func (p *PlayerNetwork) PacketLoss() float32
- func (p *PlayerNetwork) RTT() float32
- func (p *PlayerNetwork) ReceivePacket(pkt *PacketUDP, recvTime time.Time, addr *net.UDPAddr, ...)
- func (p *PlayerNetwork) RecvBandwidth() float32
- func (p *PlayerNetwork) RemoteSequence() uint16
- func (p *PlayerNetwork) SendPacket(protocol uint16, datatype uint8, data []byte, reaible bool) error
- func (p *PlayerNetwork) SendPacketToUDP(protocol uint16, datatype uint8, data []byte, addr *net.UDPAddr, reaible bool) error
- func (p *PlayerNetwork) SentBandwidth() float32
- func (p *PlayerNetwork) Update(now time.Time)
- type ReaibleAck
Constants ¶
const ( AckSize = 32 RttSmoothingFactor = 0.0025 PacketLossSmoothingFactor = 0.50 BandwidthSmoothingFactor = 0.10 )
const ( // SizeUint8 is the byte size of a uint8. SizeUint8 = 1 // SizeUint16 is the byte size of a uint16. SizeUint16 = 2 // SizeUint32 is the byte size of a uint32. SizeUint32 = 4 // SizeUint64 is the byte size of a uint64. SizeUint64 = 8 // SizeInt8 is the byte size of a int8. SizeInt8 = 1 // SizeInt16 is the byte size of a int16. SizeInt16 = 2 // SizeInt32 is the byte size of a int32. SizeInt32 = 4 // SizeInt64 is the byte size of a int64. SizeInt64 = 8 // SizeFloat32 is the byte size of a float32. SizeFloat32 = 4 // SizeFloat64 is the byte size of a float64. SizeFloat64 = 8 // SizeByte is the byte size of a byte. // The `byte` type is aliased (by Go definition) to uint8. SizeByte = 1 // SizeBool is the byte size of a bool. // The `bool` type is aliased (by flatbuffers convention) to uint8. SizeBool = 1 // SizeSOffsetT is the byte size of an SOffsetT. // The `SOffsetT` type is aliased (by flatbuffers convention) to int32. SizeSOffsetT = 4 // SizeUOffsetT is the byte size of an UOffsetT. // The `UOffsetT` type is aliased (by flatbuffers convention) to uint32. SizeUOffsetT = 4 // SizeVOffsetT is the byte size of an VOffsetT. // The `VOffsetT` type is aliased (by flatbuffers convention) to uint16. SizeVOffsetT = 2 )
const DATA_SIZE_BYTES = 15
const PACKET_UDP_HEADER_BYTES = 17
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct { Buf []byte // the backing byte slice Pos int // current position in read/write }
Buffer is a helper struct for serializing and deserializing as the caller does not need to externally manage where in the buffer they are currently reading or writing to.
func NewBufferFromBytes ¶
Creates a new buffer from a byte slice
func NewBufferFromRef ¶
Creates a new Buffer using the original backing slice
func (*Buffer) GetBytes ¶
GetBytes returns a byte slice possibly smaller than length if bytes are not available from the reader.
func (*Buffer) WriteBytes ¶
WriteBytes encodes a little-endian byte slice into the buffer
func (*Buffer) WriteBytesN ¶
WriteBytes encodes a little-endian byte slice into the buffer
func (*Buffer) WriteFloat32 ¶
WriteFloat32 encodes a little-endian float32 into the buffer.
func (*Buffer) WriteFloat64 ¶
WriteFloat64 encodes a little-endian float64 into the buffer.
func (*Buffer) WriteInt16 ¶
WriteInt16 encodes a little-endian int16 into the buffer.
func (*Buffer) WriteInt32 ¶
WriteInt32 encodes a little-endian int32 into the buffer.
func (*Buffer) WriteInt64 ¶
WriteInt64 encodes a little-endian int64 into the buffer.
func (*Buffer) WriteUint16 ¶
WriteUint16 encodes a little-endian uint16 into the buffer.
func (*Buffer) WriteUint32 ¶
WriteUint32 encodes a little-endian uint32 into the buffer.
func (*Buffer) WriteUint64 ¶
WriteUint64 encodes a little-endian uint64 into the buffer.
func (*Buffer) WriteUint8 ¶
WriteUint8 encodes a little-endian uint8 into the buffer.
type PacketUDP ¶
type PlayerNetwork ¶
type PlayerNetwork struct {
// contains filtered or unexported fields
}
func NewPlayerNetwork ¶
func NewPlayerNetwork(conn *net.UDPConn, session uint32) *PlayerNetwork
func (*PlayerNetwork) AckBandwidth ¶
func (p *PlayerNetwork) AckBandwidth() float32
func (*PlayerNetwork) PacketLoss ¶
func (p *PlayerNetwork) PacketLoss() float32
func (*PlayerNetwork) RTT ¶
func (p *PlayerNetwork) RTT() float32
func (*PlayerNetwork) ReceivePacket ¶
func (*PlayerNetwork) RecvBandwidth ¶
func (p *PlayerNetwork) RecvBandwidth() float32
func (*PlayerNetwork) RemoteSequence ¶
func (p *PlayerNetwork) RemoteSequence() uint16
func (*PlayerNetwork) SendPacket ¶
func (*PlayerNetwork) SendPacketToUDP ¶
func (*PlayerNetwork) SentBandwidth ¶
func (p *PlayerNetwork) SentBandwidth() float32
func (*PlayerNetwork) Update ¶ added in v1.1.0
func (p *PlayerNetwork) Update(now time.Time)