Documentation ¶
Index ¶
- Variables
- func MarshalBlockBytes(block BlockData) ([]byte, error)
- type Block
- type BlockData
- type BlockHeader
- type Decoder
- type Frame
- type GenericBlockData
- func (GenericBlockData) IsBlockData()
- func (b *GenericBlockData) Length() uint32
- func (b *GenericBlockData) MarshalBytes() ([]byte, error)
- func (b *GenericBlockData) MarshalJSON() ([]byte, error)
- func (b *GenericBlockData) UnmarshalBytes(data []byte) error
- func (b *GenericBlockData) UnmarshalJSON(data []byte) error
- type Header
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidHeader = errors.New("invalid header")
ErrInvalidHeader is an error that is returned when the frame header is not something that is recognized by the decoder.
var ErrNotEnoughData = errors.New("not enough data in packets buffer")
ErrNotEnoughData is an error that is returned when there is not ErrNotEnoughData data to process the packet
Functions ¶
func MarshalBlockBytes ¶
MarshalBlockBytes returns the byte representation of the block data
Types ¶
type Block ¶
type Block struct { Length uint32 Header BlockHeader Data BlockData }
Block defines the structure of a block in an FFXIV frame
func (*Block) CorrectLength ¶
func (b *Block) CorrectLength()
CorrectLength computes the true length of the block and sets its Length field
type BlockData ¶
type BlockData interface {
IsBlockData()
}
BlockData defines the interface for the XIVWS representation of FFXIV block data
type BlockHeader ¶
type BlockHeader struct { SubjectID uint32 CurrentID uint32 U1 uint32 U2 uint16 Opcode uint16 Route uint32 Time time.Time U4 uint32 }
BlockHeader defines the type for a 28 byte array
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder implements an FFXIV frame decoder
func NewDecoder ¶
NewDecoder creates a new instance of a decoder
func (*Decoder) CheckHeader ¶
CheckHeader checks to see whether or not the data in the buffer has a valid header
func (*Decoder) Decode ¶
Decode returns a single decoded FFXIV frame from the packet data stored in buf
func (*Decoder) DiscardDataUntilValid ¶ added in v1.44.2
DiscardDataUntilValid will trim off invalid data on the buffered input until it reaches a header that is valid or the buffer has insufficient data. This is useful for when the input stream has been corrupted with some invalid bytes.
type Frame ¶
type Frame struct { Header Header Time time.Time Length uint32 Reserved1 uint16 NumBlocks uint16 Compression uint16 Reserved2 uint32 Reserved3 uint16 Blocks []*Block // contains filtered or unexported fields }
Frame defines the structure for an FFXIV Frame
func (*Frame) CompressBlocks ¶
CompressBlocks prepares the frame for writing by saving an internal representation of the compressed block bytes
func (*Frame) CorrectLength ¶
func (f *Frame) CorrectLength()
CorrectLength corrects the length in the FFXIV frame header. This method assumes all the block header lengths are correct.
func (*Frame) CorrectTimestamps ¶
CorrectTimestamps corrects the timestamps in the FFXIV frame header and its blocks
type GenericBlockData ¶
type GenericBlockData []byte
GenericBlockData defines the type for a variable length byte slice
func GenericBlockDataFromBytes ¶
func GenericBlockDataFromBytes(blockData []byte) *GenericBlockData
GenericBlockDataFromBytes is a helper that creates a GenericBlockData from raw bytes
func (GenericBlockData) IsBlockData ¶ added in v1.45.2
func (GenericBlockData) IsBlockData()
func (*GenericBlockData) Length ¶
func (b *GenericBlockData) Length() uint32
Length returns the length of the block data
func (*GenericBlockData) MarshalBytes ¶
func (b *GenericBlockData) MarshalBytes() ([]byte, error)
MarshalBytes returns the byte representation of the block data
func (*GenericBlockData) MarshalJSON ¶
func (b *GenericBlockData) MarshalJSON() ([]byte, error)
MarshalJSON returns the marshaled version of the BlockHeader
func (*GenericBlockData) UnmarshalBytes ¶
func (b *GenericBlockData) UnmarshalBytes(data []byte) error
UnmarshalBytes sets the block data to the provided raw bytes
func (*GenericBlockData) UnmarshalJSON ¶
func (b *GenericBlockData) UnmarshalJSON(data []byte) error
UnmarshalJSON returns the unmarshaled version of the BlockHeader
type Header ¶
type Header [16]byte
Header defines the type for a 16 byte array
func (*Header) MarshalJSON ¶
MarshalJSON returns the marshaled version of the frame header
func (*Header) UnmarshalJSON ¶
UnmarshalJSON returns the unmarshaled version of the frame header