codecs

package
v3.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EchoReplayTimeFormat = "2006/01/02 15:04:05.000"
)

Variables

View Source
var (
	ErrCodecNotConfiguredForWriting = fmt.Errorf("codec not configured for writing")
)

Functions

func FixProtojsonUint64Encoding

func FixProtojsonUint64Encoding(data []byte) []byte

FixProtojsonUint64Encoding converts protojson string-encoded uint64 fields back to raw numbers. protojson encodes uint64 as JSON strings per proto3 spec (e.g., "userid":"123"), but the original game engine outputs them as numbers (e.g., "userid":123). This function transforms the JSON to match the original game format for compatibility with third-party echoreplay parsers.

This implementation uses direct byte manipulation for performance, avoiding regex overhead.

Types

type EchoReplay

type EchoReplay struct {
	// contains filtered or unexported fields
}

EchoReplay handles .echoreplay file format (zip format)

func NewEchoReplayReader

func NewEchoReplayReader(filename string) (*EchoReplay, error)

NewEchoReplayReader creates a new EchoReplay codec for reading

func NewEchoReplayWriter

func NewEchoReplayWriter(filename string) (*EchoReplay, error)

NewEchoReplayWriter creates a new EchoReplay codec for writing

func (*EchoReplay) Close

func (e *EchoReplay) Close() error

Close closes the codec and underlying files

func (*EchoReplay) Finalize

func (e *EchoReplay) Finalize() error

Finalize writes the buffered data to the zip file and closes it

func (*EchoReplay) FlushBuffer

func (e *EchoReplay) FlushBuffer() error

FlushBuffer forces a flush of the internal buffer (useful for periodic flushing)

func (*EchoReplay) GetBufferSize

func (e *EchoReplay) GetBufferSize() int

GetBufferSize returns the current size of the internal buffer

func (*EchoReplay) HasNext

func (e *EchoReplay) HasNext() bool

HasNext checks if there are more frames to read

func (*EchoReplay) ReadFrame

func (e *EchoReplay) ReadFrame() (*telemetry.LobbySessionStateFrame, error)

ReadFrame reads the next frame from the .echoreplay file

func (*EchoReplay) ReadFrameTo

func (e *EchoReplay) ReadFrameTo(frame *telemetry.LobbySessionStateFrame) (bool, error)

ReadFrameTo reads the next frame into the provided frame object to avoid allocations. Returns true if a frame was read, false if EOF or error. The frame parameter must be non-nil.

func (*EchoReplay) ReadFrames

func (e *EchoReplay) ReadFrames() ([]*telemetry.LobbySessionStateFrame, error)

ReadFrames reads all frames from the .echoreplay file

func (*EchoReplay) ReadTo

func (e *EchoReplay) ReadTo(frames []*telemetry.LobbySessionStateFrame) (int, error)

ReadTo reads frames into the provided slice and returns the number of frames read. This avoids allocations by reusing the caller's slice. Returns the number of frames read and any error encountered. If the slice is filled before EOF, it returns the count with no error.

func (*EchoReplay) WriteFrame

func (e *EchoReplay) WriteFrame(frame *telemetry.LobbySessionStateFrame) error

WriteFrame writes a frame to the .echoreplay file using optimized buffer operations

func (*EchoReplay) WriteFrameBatch

func (e *EchoReplay) WriteFrameBatch(frames []*telemetry.LobbySessionStateFrame) error

WriteFrameBatch writes multiple frames efficiently in a single operation

func (*EchoReplay) WriteReplayFrame

func (e *EchoReplay) WriteReplayFrame(dst *bytes.Buffer, frame *telemetry.LobbySessionStateFrame) int

WriteReplayFrame writes a frame using optimized buffer operations (same approach as writer_replay_file.go)

type EchoReplayFrame

type EchoReplayFrame struct {
	Timestamp   string                       `json:"timestamp"`
	Session     *apigame.SessionResponse     `json:"session"`
	PlayerBones *apigame.PlayerBonesResponse `json:"user_bones,omitempty"`
}

EchoReplayFrame represents a frame in the .echoreplay format

type NevrCap

type NevrCap struct {
	// contains filtered or unexported fields
}

NevrCap handles streaming to/from Zstd-compressed .nevrcap files

func NewNevrCapReader

func NewNevrCapReader(filename string) (*NevrCap, error)

NewNevrCapReader creates a new Zstd codec for reading .nevrcap files

func NewNevrCapWriter

func NewNevrCapWriter(filename string) (*NevrCap, error)

NewNevrCapWriter creates a new Zstd codec for writing .nevrcap files

func (*NevrCap) Close

func (z *NevrCap) Close() error

Close closes the codec and underlying file

func (*NevrCap) ReadFrame

func (z *NevrCap) ReadFrame() (*telemetry.LobbySessionStateFrame, error)

ReadFrame reads a frame from the file

func (*NevrCap) ReadFrameTo

func (z *NevrCap) ReadFrameTo(frame *telemetry.LobbySessionStateFrame) (bool, error)

ReadFrameTo reads a frame into the provided frame object

func (*NevrCap) ReadHeader

func (z *NevrCap) ReadHeader() (*telemetry.TelemetryHeader, error)

ReadHeader reads the nevrcap header from the file

func (*NevrCap) WriteFrame

func (z *NevrCap) WriteFrame(frame *telemetry.LobbySessionStateFrame) error

WriteFrame writes a frame to the file

func (*NevrCap) WriteHeader

func (z *NevrCap) WriteHeader(header *telemetry.TelemetryHeader) error

WriteHeader writes the nevrcap header to the file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL