Documentation
¶
Index ¶
- type Packet
- func (p *Packet) AddBitmask(value int, numBits int) *Packet
- func (p *Packet) AddBoolean(b bool) *Packet
- func (p *Packet) AddBytes(b []byte) *Packet
- func (p *Packet) AddEncryptedString(s string) *Packet
- func (p *Packet) AddFramedString(s string) *Packet
- func (p *Packet) AddInt8(b int8) *Packet
- func (p *Packet) AddSignedBits(value int, numBits int) *Packet
- func (p *Packet) AddSmart0816(i int) *Packet
- func (p *Packet) AddSmart0832(i int) *Packet
- func (p *Packet) AddSmart1632(i int) *Packet
- func (p *Packet) AddString(s string) *Packet
- func (p *Packet) AddUint16(s uint16) *Packet
- func (p *Packet) AddUint32(i uint32) *Packet
- func (p *Packet) AddUint64(l uint64) *Packet
- func (p *Packet) AddUint8(b uint8) *Packet
- func (p *Packet) AddUint8or32(i uint32) *Packet
- func (p *Packet) Available() int
- func (p *Packet) Capacity() int
- func (p *Packet) EnsureCapacity(l int)
- func (p *Packet) Flip()
- func (p *Packet) Length() int
- func (p *Packet) Read(buf []byte) int
- func (p *Packet) ReadBoolean() bool
- func (p *Packet) ReadInt8() int8
- func (p *Packet) ReadString() string
- func (p *Packet) ReadStringN(n int) (val string)
- func (p *Packet) ReadUByte() byte
- func (p *Packet) ReadUint128() (lsb uint64, msb uint64)
- func (p *Packet) ReadUint16() int
- func (p *Packet) ReadUint32() int
- func (p *Packet) ReadUint64() uint64
- func (p *Packet) ReadUint8() uint8
- func (p *Packet) Rewind(n int) error
- func (p *Packet) Skip(n int) error
- func (p *Packet) String() string
- func (p *Packet) WriteIndex() int
- type WriteFlusher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Packet ¶
type Packet struct { Opcode byte FrameBuffer []byte ReadIndex int Bare bool // contains filtered or unexported fields }
Packet The definition of a game handlers. Generally, these are commands, indexed by their Opcode(0-255), with
a 5000-byte buffer for arguments, stored in FrameBuffer. If the handlers is bare, raw data is intended to be transmitted when writing the handlers structure to a socket, otherwise we put a 2-byte unsigned short for the length of the arguments buffer(plus one because the opcode is included in the payload size), and the 1-byte opcode at the start of the handlers, as a header for the client to easily parse the information for each frame.
func NewEmptyPacket ¶
NewEmptyPacket Creates a new handlers instance intended for sending formatted data to the client.
func NewReplyPacket ¶
NewReplyPacket Creates a new handlers instance intended for sending raw data to the client.
func (*Packet) AddBitmask ¶
AddBitmask Packs value into the numBits next bits of the packetbuilders byte buffer. Note: This method only keeps track of the data that it has written to the buffer; it will overwrite any non-bitmasked values in the buffer starting at the beginning.
func (*Packet) AddBoolean ¶
AddBoolean Adds a single byte to the payload, with the value 1 if b is true, and 0 if b is false.
func (*Packet) AddEncryptedString ¶
func (*Packet) AddFramedString ¶
func (*Packet) AddSignedBits ¶
AddSignedBits adds the value with the first bit masked off
func (*Packet) AddSmart0816 ¶
func (*Packet) AddSmart0832 ¶
func (*Packet) AddSmart1632 ¶
func (*Packet) AddUint8or32 ¶
AddUint8or32 Adds a 32-bit integer or an 8-byte integer to the handlers payload, depending on value. TODO: Deprecate and remove this in favor of above, improved name
func (*Packet) EnsureCapacity ¶
func (*Packet) ReadBoolean ¶
ReadBoolean Returns true if the next payload byte isn't 0
func (*Packet) ReadString ¶
ReadString Read the next variable-length C-string from the handlers payload and return it as a Go-string. This will keep reading data until it reaches a string termination byte. String termination bytes in order of precedence: NULL (hex:0x00, escape-seq:'\x00', decimal:0); NewLine/LineFeed (hex:0xA, escape-seq:'\n', decimal:10)
func (*Packet) ReadStringN ¶
ReadStringN Reads the next n bytes from the payload and returns it as a UTF-8 string, regardless of payload contents.
func (*Packet) ReadUint128 ¶
ReadUint128 Read the next 128-bit integer from the handlers payload, returns it as 2 uint64 words,
func (*Packet) ReadUint16 ¶
ReadUint16 Read the next 16-bit integer from the handlers payload.
func (*Packet) ReadUint32 ¶
ReadUint32 Read the next 32-bit integer from the handlers payload.
func (*Packet) ReadUint64 ¶
ReadUint64 Read the next 64-bit integer from the handlers payload.