codec

package
v0.0.0-...-a152d5b Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JsonCodec

type JsonCodec struct{}

func (*JsonCodec) NewPacket

func (_ *JsonCodec) NewPacket() socketcrutch.Packet

func (*JsonCodec) ReadMode

func (_ *JsonCodec) ReadMode() int

func (*JsonCodec) WriteMode

func (_ *JsonCodec) WriteMode() int

type Packet

type Packet struct {
	Type  byte   `json:"type"`
	Id    int    `json:"id"`
	Event string `json:"event"`
	Data  []byte `json:"payload"`
}

packet is container for raw data and therefore holds the event name, the pointer to payload, the event type id, the packet id.

func (*Packet) GetEventName

func (p *Packet) GetEventName() string

func (*Packet) GetType

func (p *Packet) GetType() socketcrutch.PacketType

func (*Packet) ID

func (p *Packet) ID() int

func (Packet) Marshal

func (v Packet) Marshal() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (Packet) MarshalEasyJSON

func (v Packet) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*Packet) Payload

func (p *Packet) Payload() []byte

func (*Packet) SetEventName

func (p *Packet) SetEventName(name string)

func (*Packet) SetID

func (p *Packet) SetID(id int)

func (*Packet) SetPayload

func (p *Packet) SetPayload(payload []byte)

func (*Packet) SetType

func (p *Packet) SetType(pType socketcrutch.PacketType)

func (*Packet) Unmarshal

func (v *Packet) Unmarshal(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

func (*Packet) UnmarshalEasyJSON

func (v *Packet) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

Jump to

Keyboard shortcuts

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