Documentation ¶
Index ¶
- Constants
- func MarshalBlockBytes(block BlockData) ([]byte, error)
- type Block
- type BlockData
- type Decoder
- type DecodingError
- type EOFError
- 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)
- func (b *GenericBlockData) UnmarshalJSON(data []byte) error
- type IPCHeader
- type InvalidFrameLengthError
- type InvalidHeaderError
- type OodleImpl
- type Preamble
Constants ¶
const ( BlockTypeSessionInit = 1 BlockTypeSessionRecv = 2 BlockTypeIPC = 3 BlockTypePing = 7 BlockTypePong = 8 BlockTypeEncryptInit = 9 BlockTypeEncryptRecv = 10 )
These constants indicate the type of block.
const FFXIV_PATCH_VERSION = "6.38"
FFXIV_PATCH_VERSION defines the exact patch version of FFXIV that this library supports.
Variables ¶
This section is empty.
Functions ¶
func MarshalBlockBytes ¶
MarshalBlockBytes returns the byte representation of the block data
Types ¶
type Block ¶
type Block struct { Length uint32 // [0:4] - Total block size, including the header SubjectID uint32 // [4:8] - The session ID that this block describes CurrentID uint32 // [8:12] - The session ID of the sender/receiver of this block Type uint16 // [12:14] - The segment type Pad1 uint16 // [14:16] IPCHeader // [16:32] if Type == BlockTypeIPC Data BlockData }
Block defines the structure of a block in an FFXIV frame. More details in Sapphire's `Network/CommonNetwork.h`.
func (Block) CorrectLength ¶
CorrectLength returns the true length of the block
type BlockData ¶
type BlockData interface {
IsBlockData()
}
BlockData defines the interface for the XIVWS representation of FFXIV block data
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder implements an FFXIV frame decoder. It is not thread-safe, so consumers need to be sure not to use it concurrently.
func NewDecoder ¶
NewDecoder creates a new instance of a frame decoder. bufSize controls the total size of the buffer used to store a single frame. It's recommended to keep this value at least 8192, since this value generally works for all frames (as far as I can tell).
func NewDecoderWithOodle ¶ added in v3.35.0
func (*Decoder) CheckHeader ¶
CheckHeader checks to see whether or not the data in the buffer has a valid header
func (*Decoder) DiscardDataUntilValid ¶
func (d *Decoder) DiscardDataUntilValid()
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 DecodingError ¶
type DecodingError struct {
// contains filtered or unexported fields
}
DecodingError is returned whenenever some error occurs while decoding the frame or some block within the frame.
func (DecodingError) Error ¶
func (e DecodingError) Error() string
type EOFError ¶
type EOFError struct {
// contains filtered or unexported fields
}
EOFError is an error that is returned when there is not enough data to process the packet
type Frame ¶
type Frame struct { Preamble Preamble // [0:16] - Used to identify the start of a frame Time time.Time // [16:24] - Number of milliseconds since the Unix epoch Length uint32 // [24:28] - Total frame size, including the header ConnectionType uint16 // [28:30] - Connection type (0 lobby, 1 zone, 2 chat) Count uint16 // [30:32] - Number of blocks in this frame Reserved1 byte // [32] - Usually 1 Compression byte // [33] - 1 if compressed, 0 if not Reserved2 uint16 // [34:36] DecompressedLength uint32 // [36:40] Blocks []*Block }
Frame defines the structure for an FFXIV Frame. More details in Sapphire's `Network/CommonNetwork.h`. The Frame header is encoded as 40 bytes on the wire.
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 ¶
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 generic block data
func (GenericBlockData) MarshalJSON ¶
func (b GenericBlockData) MarshalJSON() ([]byte, error)
MarshalJSON returns the marshaled version of the generic block data
func (*GenericBlockData) UnmarshalBytes ¶
func (b *GenericBlockData) UnmarshalBytes(data []byte)
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 generic block data
type IPCHeader ¶
type IPCHeader struct { Reserved uint16 // [16:18] - 0x14 Opcode uint16 // [18:20] - Type of IPC message Pad2 uint16 // [20:22] ServerID uint16 // [22:24] - Server ID handling this message Time time.Time // [24:28] - Number of seconds since Unix epoch Pad3 uint32 // [28:32] }
IPCHeader defines the type for the IPC header of an FFXIV block. In cases other than SEGMENTTYPE_IPC, this header will not be present.
type InvalidFrameLengthError ¶
type InvalidFrameLengthError struct {
// contains filtered or unexported fields
}
InvalidFrameLength is an error that is returned when the frame specifies a length that is too large. This error guards against the case when garbage or malicious data is read as part of decoding.
func (InvalidFrameLengthError) Error ¶
func (e InvalidFrameLengthError) Error() string
type InvalidHeaderError ¶
type InvalidHeaderError struct {
// contains filtered or unexported fields
}
InvalidHeaderError is an error that is returned when the frame header is not something that is recognized by the decoder. It uses a string as a field to guarantee that the header is copied, so that changes to the original buffer don't affect the error.
func (InvalidHeaderError) Error ¶
func (e InvalidHeaderError) Error() string
type Preamble ¶
type Preamble [16]byte
Preamble defines the type for a 16 byte array
func (*Preamble) MarshalJSON ¶
MarshalJSON returns the marshaled version of the frame magic
func (*Preamble) UnmarshalJSON ¶
UnmarshalJSON returns the unmarshaled version of the frame magic