codec

package
v0.0.0-...-0917785 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: Unlicense Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const (
	FeslAccount     = "acct"
	FeslSystem      = "fsys"
	FeslGameSummary = "gsum"
	FeslPlayNow     = "pnow"
	FeslRanking     = "rank"
	FeslAssociation = "asso" // TODO: Not implemented
	FeslBlob        = "blob" // TODO: Not implemented
	FeslFeedback    = "fdbk" // TODO: Not implemented
	FeslFilter      = "fltr" // TODO: Not implemented
	FeslFindPlayer  = "fpla" // TODO: Not implemented
	FeslPresence    = "pres" // TODO: Not implemented
	FeslRecorder    = "recp" // TODO: Not implemented

	ThtrCreateGame           = "CGAM"
	ThtrConnect              = "CONN"
	ThtrEcho                 = "ECHO"
	ThtrEnterGame            = "EGAM"
	ThtrEnterGameEntitleGame = "EGEG"
	ThtrEnterGameRequest     = "EGRQ"
	ThtrEnterGameResponse    = "EGRS"
	ThtrEnterConnectionLost  = "ECNL"
	ThtrGamesData            = "GDAT"
	ThtrGamesList            = "GLST"
	ThtrKickPlayer           = "KICK"
	ThtrLobbyData            = "LDAT"
	ThtrLobbyList            = "LLST"
	ThtrPlayerEnter          = "PENT"
	ThtrPing                 = "PING"
	ThtrPlayerValidator      = "PLVT"
	ThtrUpdateBrokerRating   = "UBRA"
	ThtrUpdatePlayer         = "UPLA"
	ThtrUser                 = "USER"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BufWriter

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

func (*BufWriter) Bytes

func (e *BufWriter) Bytes() []byte

func (*BufWriter) Len

func (e *BufWriter) Len() int

func (*BufWriter) WriteByte

func (e *BufWriter) WriteByte(b byte)

func (*BufWriter) WriteString

func (e *BufWriter) WriteString(s string)

type Command

type Command struct {
	Query     string
	Message   Fields
	PayloadID uint32
}

func NewCommand

func NewCommand(pkt *RawPacket) (*Command, error)

func ParseCommands

func ParseCommands(data []byte) ([]*Command, error)

type EncOptions

type EncOptions struct {
	OmitEmpty bool
}

type EncWriter

type EncWriter interface {
	WriteString(string)
	WriteByte(byte)
	Len() int
	Bytes() []byte
}

type Encoder

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

func NewEncoder

func NewEncoder() *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(v interface{}) (err error)

func (*Encoder) EncodePacket

func (e *Encoder) EncodePacket(Packet *Packet) (*bytes.Buffer, error)

type Fields

type Fields map[string]string

Fields contains payload of FESL response converted as a go-lang friendly map

func DecodeFESL

func DecodeFESL(data []byte) Fields

func (Fields) ArrayStrings

func (m Fields) ArrayStrings(prefix string) []string

ArrayStrings scraps all items in specified key as a array

func (Fields) Exists

func (m Fields) Exists(key string) bool

Exists checks if specified key was defined

func (Fields) FloatAsInt

func (m Fields) FloatAsInt(key string) (int, int, error)

FloatAsInt attempts to guess precision and cast float as an integer. It allows to take care of floating point math inaccuracy (0.1+0.2 != 0.3)

func (Fields) FloatVal

func (m Fields) FloatVal(key string) (float64, error)

FloatVal tries to cast specified value as a float

func (Fields) Get

func (m Fields) Get(key string) string

Get returns string value Note: String() in somehow reserved in golang (like toString() in C#)

func (Fields) IntArr

func (m Fields) IntArr(key, sep string) []int

IntArr explodes an encoded array which is separated by commas

func (Fields) IntVal

func (m Fields) IntVal(key string) (int, error)

IntVal tries to cast specified value as an integer

func (Fields) StrArr

func (m Fields) StrArr(key, sep string) []string

StrArr explodes an encoded array which is separated by semicolons

type Packet

type Packet struct {
	Message string
	Send    uint32
	Content interface{}
}

type RawPacket

type RawPacket struct {
	// Query first 4 bytes
	// i.e. "fsys", "acct" "CONN", "UPLA"
	Query []byte

	// Broadcast, next 4 bytes
	// TOOD: Use enumerator
	Broadcast []byte

	// Length, next 4 bytes
	Length []byte

	// Payload
	Payload []byte
}

func ExtractPacket

func ExtractPacket(buf *bytes.Buffer) (*RawPacket, error)

Jump to

Keyboard shortcuts

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