Documentation ¶
Index ¶
- Constants
- Variables
- func GetVariableLengthBytes(val uint16) (int, error)
- func PacketMaxValues(maxPacketSizeBytes int64) (int, int, error)
- func ReadFragmentHeader(packetBuffer []byte, offset, bufferLength, maxFragments, fragmentSize int) (int, int, int, int, uint16, uint16, uint32, byte, error)
- func ReadPacketHeader(packetBuffer []byte, offset, bufferLength int) (int, byte, uint16, uint16, uint32, error)
- func ReadVariableLengthUint16(rw *ByteArrayReaderWriter) (uint16, error)
- func SequenceGreaterThan(s1, s2 uint16) bool
- func SequenceLessThan(s1, s2 uint16) bool
- func WriteAckPacket(packetBuffer []byte, channelID byte, ack uint16, ackBits uint32) int
- func WritePacketHeader(packetBuffer []byte, channelID byte, sequence uint16, ack uint16, ...) int
- func WriteVariableLengthUint16(val uint16, rw *ByteArrayReaderWriter) error
- type BufferedPacket
- type ByteArrayReaderWriter
- func (s *ByteArrayReaderWriter) ReadBuffer(buf []byte, length int) error
- func (s *ByteArrayReaderWriter) ReadByte() (byte, error)
- func (s *ByteArrayReaderWriter) ReadUint16() (uint16, error)
- func (s *ByteArrayReaderWriter) SeekRead(offset int) int
- func (s *ByteArrayReaderWriter) SeekWrite(offset int) int
- func (s *ByteArrayReaderWriter) WriteBuffer(buf []byte, length int)
- func (s *ByteArrayReaderWriter) WriteByte(b byte)
- func (s *ByteArrayReaderWriter) WriteUint16(u uint16)
- type ClientInstance
- type FragmentReassemblyPacketData
- type NetcodeConn
- type NetcodeData
- type PacketSet
- type ReceivedPacketData
- type ReliablePacketController
- func (r *ReliablePacketController) ReceivePacket(time int64, packetData []byte, bufferLength int) (uint16, []byte, int, []uint16, error)
- func (r *ReliablePacketController) SendAck(channelID byte) ([]byte, int)
- func (r *ReliablePacketController) SendPacket(time int64, packetData []byte, length int, channelID byte) (uint16, [][]byte, []int, error)
- func (r *ReliablePacketController) Update()
- type SentPacketData
- type SequenceBufferOutgoing
- type SequenceBufferPacket
- func (s *SequenceBufferPacket) Exists(sequence uint16) bool
- func (s *SequenceBufferPacket) Find(sequence uint16) *BufferedPacket
- func (s *SequenceBufferPacket) Insert(sequence uint16) *BufferedPacket
- func (s *SequenceBufferPacket) Remove(sequence uint16)
- func (s *SequenceBufferPacket) RemoveEntries(startSequence, finishSequence int32)
- type SequenceBufferReassembly
- func (s *SequenceBufferReassembly) Find(sequence uint16) *FragmentReassemblyPacketData
- func (s *SequenceBufferReassembly) Insert(sequence uint16) *FragmentReassemblyPacketData
- func (s *SequenceBufferReassembly) Remove(sequence uint16)
- func (s *SequenceBufferReassembly) RemoveEntries(startSequence, finishSequence int32)
- type SequenceBufferReceived
- func (s *SequenceBufferReceived) Exists(sequence uint16) bool
- func (s *SequenceBufferReceived) Find(sequence uint16) *ReceivedPacketData
- func (s *SequenceBufferReceived) GenerateAckBits() (uint16, uint32)
- func (s *SequenceBufferReceived) Insert(sequence uint16) *ReceivedPacketData
- func (s *SequenceBufferReceived) RemoveEntries(startSequence, finishSequence int32)
- func (s *SequenceBufferReceived) TestInsert(sequence uint16) bool
- type SequenceBufferSent
- type Server
Constants ¶
View Source
const ( KEEP_ALIVE_RESOLUTION = 4 RELIABLE_CHANNEL_ID = byte(0) UNRELIABLE_CHANNEL_ID = byte(1) )
View Source
const ( MAX_PACKET_HEADER_BYTES = 10 FRAGMENT_HEADER_BYTES = 6 NULL_SEQUENCE = uint32(0xFFFFFFFF) )
View Source
const FRAGMENT_SIZE = 1024
View Source
const MAX_CLIENTS = 1024
Not a true connection limit, only used to initialise/allocate various buffer and data structure sizes.
Variables ¶
View Source
var ErrClientInstanceClosed = errors.New("client instance closed")
View Source
var ErrClientInstanceNotConnected = errors.New("client instance not connected")
View Source
var ErrClientInstanceSendBufferFull = errors.New("client instance reliable send buffer full")
View Source
var ErrClientInstanceUnreliableDataTooLarge = errors.New("client instance unreliable data too large")
View Source
var ErrReliablePacketControllerPacketDataTooLarge = errors.New("reliable packet controller packet data too large")
View Source
var ErrValueOutOfRange = errors.New("variable length value out of range")
Functions ¶
func GetVariableLengthBytes ¶
func ReadFragmentHeader ¶
func ReadPacketHeader ¶
func ReadVariableLengthUint16 ¶
func ReadVariableLengthUint16(rw *ByteArrayReaderWriter) (uint16, error)
func SequenceGreaterThan ¶
func SequenceLessThan ¶
func WriteAckPacket ¶
func WritePacketHeader ¶
func WriteVariableLengthUint16 ¶
func WriteVariableLengthUint16(val uint16, rw *ByteArrayReaderWriter) error
Types ¶
type BufferedPacket ¶
type BufferedPacket struct {
// contains filtered or unexported fields
}
func (*BufferedPacket) Resize ¶
func (b *BufferedPacket) Resize(size int)
type ByteArrayReaderWriter ¶
type ByteArrayReaderWriter struct {
// contains filtered or unexported fields
}
func NewByteArrayReaderWriter ¶
func NewByteArrayReaderWriter(data []byte) *ByteArrayReaderWriter
TODO Cache and reuse?
func (*ByteArrayReaderWriter) ReadBuffer ¶
func (s *ByteArrayReaderWriter) ReadBuffer(buf []byte, length int) error
func (*ByteArrayReaderWriter) ReadByte ¶
func (s *ByteArrayReaderWriter) ReadByte() (byte, error)
func (*ByteArrayReaderWriter) ReadUint16 ¶
func (s *ByteArrayReaderWriter) ReadUint16() (uint16, error)
func (*ByteArrayReaderWriter) SeekRead ¶
func (s *ByteArrayReaderWriter) SeekRead(offset int) int
Reset the read position in the stream to the given offset relative to the beginning of the stream.
func (*ByteArrayReaderWriter) SeekWrite ¶
func (s *ByteArrayReaderWriter) SeekWrite(offset int) int
Reset the read position in the stream to the given offset relative to the beginning of the stream.
func (*ByteArrayReaderWriter) WriteBuffer ¶
func (s *ByteArrayReaderWriter) WriteBuffer(buf []byte, length int)
func (*ByteArrayReaderWriter) WriteByte ¶
func (s *ByteArrayReaderWriter) WriteByte(b byte)
func (*ByteArrayReaderWriter) WriteUint16 ¶
func (s *ByteArrayReaderWriter) WriteUint16(u uint16)
type ClientInstance ¶
type ClientInstance struct { sync.Mutex Address *net.UDPAddr ExpiresAt int64 UserData []byte ProtocolId uint64 // contains filtered or unexported fields }
func NewClientInstance ¶
func NewClientInstance(logger *zap.Logger, addr *net.UDPAddr, serverConn *NetcodeConn, closeClientFn func(*ClientInstance, bool), expiry uint64, protocolId uint64, timeoutMs int64, sendKey []byte, recvKey []byte, maxPacketSize int, maxPacketFragments int) *ClientInstance
func (*ClientInstance) Close ¶
func (c *ClientInstance) Close(sendDisconnect bool)
func (*ClientInstance) IsConnected ¶
func (c *ClientInstance) IsConnected() bool
type FragmentReassemblyPacketData ¶
type FragmentReassemblyPacketData struct {
// contains filtered or unexported fields
}
func NewFragmentReassemblyPacketData ¶
func NewFragmentReassemblyPacketData() *FragmentReassemblyPacketData
func (*FragmentReassemblyPacketData) Clear ¶
func (d *FragmentReassemblyPacketData) Clear()
type NetcodeConn ¶
type NetcodeConn struct {
// contains filtered or unexported fields
}
func NewNetcodeConn ¶
func NewNetcodeConn(logger *zap.Logger, recvSize int, sendSize int, recvHandlerFn func(data *NetcodeData)) *NetcodeConn
func (*NetcodeConn) Close ¶
func (c *NetcodeConn) Close() error
type NetcodeData ¶
type NetcodeData struct {
// contains filtered or unexported fields
}
type ReceivedPacketData ¶
type ReceivedPacketData struct {
// contains filtered or unexported fields
}
type ReliablePacketController ¶
type ReliablePacketController struct {
// contains filtered or unexported fields
}
func NewReliablePacketController ¶
func NewReliablePacketController(maxPacketSize int, maxPacketFragments int) *ReliablePacketController
func (*ReliablePacketController) ReceivePacket ¶
func (*ReliablePacketController) SendAck ¶
func (r *ReliablePacketController) SendAck(channelID byte) ([]byte, int)
func (*ReliablePacketController) SendPacket ¶
func (*ReliablePacketController) Update ¶
func (r *ReliablePacketController) Update()
type SentPacketData ¶
type SentPacketData struct {
// contains filtered or unexported fields
}
type SequenceBufferOutgoing ¶
type SequenceBufferOutgoing struct {
// contains filtered or unexported fields
}
func NewSequenceBufferOutgoing ¶
func NewSequenceBufferOutgoing(bufferSize int) *SequenceBufferOutgoing
func (*SequenceBufferOutgoing) Find ¶
func (s *SequenceBufferOutgoing) Find(sequence uint16) *PacketSet
func (*SequenceBufferOutgoing) Insert ¶
func (s *SequenceBufferOutgoing) Insert(sequence uint16) *PacketSet
func (*SequenceBufferOutgoing) RemoveEntries ¶
func (s *SequenceBufferOutgoing) RemoveEntries(startSequence, finishSequence int32)
type SequenceBufferPacket ¶
type SequenceBufferPacket struct {
// contains filtered or unexported fields
}
func NewSequenceBufferPacket ¶
func NewSequenceBufferPacket(bufferSize int) *SequenceBufferPacket
func (*SequenceBufferPacket) Exists ¶
func (s *SequenceBufferPacket) Exists(sequence uint16) bool
func (*SequenceBufferPacket) Find ¶
func (s *SequenceBufferPacket) Find(sequence uint16) *BufferedPacket
func (*SequenceBufferPacket) Insert ¶
func (s *SequenceBufferPacket) Insert(sequence uint16) *BufferedPacket
func (*SequenceBufferPacket) Remove ¶
func (s *SequenceBufferPacket) Remove(sequence uint16)
func (*SequenceBufferPacket) RemoveEntries ¶
func (s *SequenceBufferPacket) RemoveEntries(startSequence, finishSequence int32)
type SequenceBufferReassembly ¶
type SequenceBufferReassembly struct {
// contains filtered or unexported fields
}
func NewSequenceBufferReassembly ¶
func NewSequenceBufferReassembly(bufferSize int) *SequenceBufferReassembly
func (*SequenceBufferReassembly) Find ¶
func (s *SequenceBufferReassembly) Find(sequence uint16) *FragmentReassemblyPacketData
func (*SequenceBufferReassembly) Insert ¶
func (s *SequenceBufferReassembly) Insert(sequence uint16) *FragmentReassemblyPacketData
func (*SequenceBufferReassembly) Remove ¶
func (s *SequenceBufferReassembly) Remove(sequence uint16)
func (*SequenceBufferReassembly) RemoveEntries ¶
func (s *SequenceBufferReassembly) RemoveEntries(startSequence, finishSequence int32)
type SequenceBufferReceived ¶
type SequenceBufferReceived struct {
// contains filtered or unexported fields
}
func NewSequenceBufferReceived ¶
func NewSequenceBufferReceived(bufferSize int) *SequenceBufferReceived
func (*SequenceBufferReceived) Exists ¶
func (s *SequenceBufferReceived) Exists(sequence uint16) bool
func (*SequenceBufferReceived) Find ¶
func (s *SequenceBufferReceived) Find(sequence uint16) *ReceivedPacketData
func (*SequenceBufferReceived) GenerateAckBits ¶
func (s *SequenceBufferReceived) GenerateAckBits() (uint16, uint32)
func (*SequenceBufferReceived) Insert ¶
func (s *SequenceBufferReceived) Insert(sequence uint16) *ReceivedPacketData
func (*SequenceBufferReceived) RemoveEntries ¶
func (s *SequenceBufferReceived) RemoveEntries(startSequence, finishSequence int32)
func (*SequenceBufferReceived) TestInsert ¶
func (s *SequenceBufferReceived) TestInsert(sequence uint16) bool
type SequenceBufferSent ¶
type SequenceBufferSent struct {
// contains filtered or unexported fields
}
func NewSequenceBufferSent ¶
func NewSequenceBufferSent(bufferSize int) *SequenceBufferSent
func (*SequenceBufferSent) Find ¶
func (s *SequenceBufferSent) Find(sequence uint16) *SentPacketData
func (*SequenceBufferSent) Insert ¶
func (s *SequenceBufferSent) Insert(sequence uint16) *SentPacketData
func (*SequenceBufferSent) RemoveEntries ¶
func (s *SequenceBufferSent) RemoveEntries(startSequence, finishSequence int32)
Click to show internal directories.
Click to hide internal directories.