Documentation
¶
Index ¶
- Constants
- Variables
- func DecodeDatagram(data []byte) ([]Range, []Frame, error)
- func EncodeDatagram(acks []Range, frames []Frame) ([]byte, error)
- func EncodeFrame(f Frame) ([]byte, int, error)
- func EncodeRPC(id uint8, payload []byte, payloadBits int) []byte
- type Conn
- func (c *Conn) AcceptedPacket() []byte
- func (c *Conn) Close() error
- func (c *Conn) Read(ctx context.Context) ([]byte, error)
- func (c *Conn) Write(ctx context.Context, payload []byte, reliability Reliability) error
- func (c *Conn) WriteChannel(ctx context.Context, payload []byte, reliability Reliability, channel uint8) error
- type Frame
- type RPC
- type Range
- type Reader
- func (r *Reader) Align() error
- func (r *Reader) Bit() (bool, error)
- func (r *Reader) Bits(count int, right bool) ([]byte, error)
- func (r *Reader) CompressedUint16() (uint16, error)
- func (r *Reader) CompressedUint32() (uint32, error)
- func (r *Reader) Float32() (float32, error)
- func (r *Reader) Int16() (int16, error)
- func (r *Reader) Remaining() int
- func (r *Reader) String8() (string, error)
- func (r *Reader) Uint8() (uint8, error)
- func (r *Reader) Uint16() (uint16, error)
- func (r *Reader) Uint32() (uint32, error)
- type Reliability
- type Split
- type Writer
- func (w *Writer) Align()
- func (w *Writer) Bit(v bool)
- func (w *Writer) Bits(data []byte, count int, right bool)
- func (w *Writer) Bytes() []byte
- func (w *Writer) CompressedUint16(v uint16)
- func (w *Writer) CompressedUint32(v uint32)
- func (w *Writer) Float32(v float32)
- func (w *Writer) Int16(v int16)
- func (w *Writer) LenBits() int
- func (w *Writer) String8(v string)
- func (w *Writer) Uint8(v uint8)
- func (w *Writer) Uint16(v uint16)
- func (w *Writer) Uint32(v uint32)
Constants ¶
const ( PacketRPC uint8 = 20 PacketTimestamp uint8 = 40 )
const (
PacketConnectionAccepted uint8 = 34
)
Variables ¶
var ( ErrClosed = errors.New("raknet: connection closed") ErrQueueFull = errors.New("raknet: queue is full") ErrHandshake = errors.New("raknet: handshake failed") ErrAttemptFailed = errors.New("raknet: connection attempt failed") ErrServerFull = errors.New("raknet: server is full") ErrServerClosed = errors.New("raknet: server closed the connection") ErrConnectionLost = errors.New("raknet: connection lost") ErrEncryption = errors.New("raknet: failed to initialize encryption") ErrBanned = errors.New("raknet: connection banned") ErrInvalidPassword = errors.New("raknet: invalid password") )
var ErrEndOfBitStream = errors.New("raknet bitstream: insufficient data")
var ErrInvalidFrame = errors.New("raknet: invalid reliability frame")
var ErrNotRPC = errors.New("raknet: packet is not an RPC")
Functions ¶
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func (*Conn) AcceptedPacket ¶
func (*Conn) Close ¶
Close mirrors RakPeer::Disconnect(500) from the native SA-MP client. The network loop owns the UDP socket and must send the reliable ordered ID_DISCONNECTION_NOTIFICATION before it exits; closing the socket first is indistinguishable from a timeout to the server.
func (*Conn) WriteChannel ¶
type Frame ¶
type Frame struct {
MessageNumber uint16
Reliability Reliability
OrderingChannel uint8
OrderingIndex uint16
Split *Split
Payload []byte
PayloadBits int
}
func DecodeFrame ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
func NewReaderBits ¶
func (*Reader) CompressedUint16 ¶
func (*Reader) CompressedUint32 ¶
type Reliability ¶
type Reliability uint8
const ( Unreliable Reliability = 6 + iota UnreliableSequenced Reliable ReliableOrdered ReliableSequenced )
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}