socketio_v5_parser_default

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 14 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrParseBinary = errors.New("parse binary error")

ErrParseBinary is returned when binary attachments cannot be reconciled with the placeholders found in a PacketBinaryEvent/PacketBinaryAck payload.

View Source
var ErrParseEvent = errors.New("parse event error")
View Source
var ErrParseEventUnsupported = errors.New("unsuported event")
View Source
var ErrParsePackage = errors.New("parse package error")

Functions

This section is empty.

Types

type BinaryPayloadParser added in v0.2.0

type BinaryPayloadParser interface {
	ReconstructBinary(msg *socketio_v5.Message, attachments [][]byte) error
}

BinaryPayloadParser is an optional capability of a custom PayloadParser. Reconstruction and WrapCallback must agree on the representation of binary values, which differs from a text-only parser's raw JSON byte slices.

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
}

type ParserOption

type ParserOption func(*SocketIOV5DefaultParser) error

func WithLogger

func WithLogger(logger Logger) ParserOption

func WithPayloadParser

func WithPayloadParser(payloadParser PayloadParser) ParserOption

type PayloadParser

type PayloadParser interface {
	ParseEvent(data []byte, emptyEvent bool) (*socketio_v5.Event, error)
	WrapCallback(callback interface{}) func(in []interface{})
}

type SocketIOV5DefaultParser

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

func NewParser

func NewParser(options ...ParserOption) (*SocketIOV5DefaultParser, error)

func (*SocketIOV5DefaultParser) HasBinary added in v0.2.0

func (p *SocketIOV5DefaultParser) HasBinary(event *socketio_v5.Event) bool

HasBinary reports whether the event carries any []byte payload that requires a PacketBinaryEvent/PacketBinaryAck encoding. Callers use it to decide between Serialize (text) and SerializeBinary.

func (*SocketIOV5DefaultParser) Parse

func (p *SocketIOV5DefaultParser) Parse(data []byte) (*socketio_v5.Message, error)

func (*SocketIOV5DefaultParser) ParseEvent

func (p *SocketIOV5DefaultParser) ParseEvent(data []byte, isAck bool) (*socketio_v5.Event, error)

func (*SocketIOV5DefaultParser) ReconstructBinary added in v0.2.0

func (p *SocketIOV5DefaultParser) ReconstructBinary(msg *socketio_v5.Message, attachments [][]byte) error

ReconstructBinary replaces every {"_placeholder":true,"num":N} marker in the message's event payloads with attachments[N], exposing the binary data as []byte. It must be called once all expected attachments (msg.BinaryAttachments) have been collected. On success BinaryAttachments is cleared so the message is indistinguishable from a fully decoded event.

func (*SocketIOV5DefaultParser) Serialize

func (p *SocketIOV5DefaultParser) Serialize(msg *socketio_v5.Message) ([]byte, error)

func (*SocketIOV5DefaultParser) SerializeBinary added in v0.2.0

func (p *SocketIOV5DefaultParser) SerializeBinary(msg *socketio_v5.Message) ([]byte, [][]byte, error)

SerializeBinary encodes a message whose event payloads contain binary data as a PacketBinaryEvent/PacketBinaryAck. It returns the header packet (with the attachment count and {"_placeholder"} markers) and the ordered list of binary attachments to send as separate frames after the header.

func (*SocketIOV5DefaultParser) WrapCallback

func (p *SocketIOV5DefaultParser) WrapCallback(callback interface{}) func(in []interface{})

Directories

Path Synopsis
jsoniter module
Package mock_socketio_v5_parser_default is a generated GoMock package.
Package mock_socketio_v5_parser_default is a generated GoMock package.

Jump to

Keyboard shortcuts

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