Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeStruct(reader io.Reader, proto IMProto, val interface{}) (err error)
- func Deserialize(payload []byte, data interface{}) (err error)
- func EncodeStruct(w io.Writer, proto IMProto, data interface{}) (err error)
- func Serialize(data interface{}) (payload []byte, err error)
- func SkipValue(reader io.Reader, proto IMProto, msgtype byte) error
- type IMProto
- type MField
- type MList
- type MMap
- type MSet
- type MStruct
- type UnsupportedTypeError
- type UnsupportedValueError
Constants ¶
Variables ¶
View Source
var MsgCodec = websocket.Codec{msglibMarshal, msglibUnmarshal}
MsgCodec is a codec to send/receive MsgLib data in a frame from a WebSocket connection.
Example:
type T struct { Msg string `msglib:"1"` Count int `msglib:"2"` } // receive Msglib type T var data T msglib.MsgCodec.Receive(ws, &data) // send MsgLib type T msglib.MsgCodec.Send(ws, data)
Functions ¶
func Deserialize ¶
Types ¶
type IMProto ¶
type IMProto interface { ReadStructBegin(reader io.Reader) (*MStruct, error) ReadFieldBegin(reader io.Reader) (*MField, error) ReadMapBegin(reader io.Reader) (*MMap, error) ReadListBegin(reader io.Reader) (*MList, error) ReadSetBegin(reader io.Reader) (*MSet, error) ReadBool(reader io.Reader) (bool, error) ReadByte(reader io.Reader) (byte, error) ReadI16(reader io.Reader) (int16, error) ReadI32(reader io.Reader) (int32, error) ReadI64(reader io.Reader) (int64, error) ReadFloat32(reader io.Reader) (float32, error) ReadFloat64(reader io.Reader) (float64, error) ReadBinary(reader io.Reader) ([]byte, error) ReadString(reader io.Reader) (string, error) WriteStructBegin(writer io.Writer, marker *MStruct) error WriteFieldBegin(writer io.Writer, marker *MField) error WriteFieldStop(writer io.Writer) error WriteMapBegin(writer io.Writer, marker *MMap) error WriteListBegin(writer io.Writer, marker *MList) error WriteSetBegin(writer io.Writer, marker *MSet) error WriteBool(writer io.Writer, data bool) error WriteByte(writer io.Writer, data byte) error WriteI16(writer io.Writer, data int16) error WriteI32(writer io.Writer, data int32) error WriteI64(writer io.Writer, data int64) error WriteFloat32(writer io.Writer, data float32) error WriteFloat64(writer io.Writer, data float64) error WriteBinary(writer io.Writer, data []byte) error WriteString(writer io.Writer, str string) error }
func NewBinaryProto ¶
func NewBinaryProto() IMProto
type UnsupportedTypeError ¶
func (*UnsupportedTypeError) Error ¶
func (e *UnsupportedTypeError) Error() string
type UnsupportedValueError ¶
func (*UnsupportedValueError) Error ¶
func (e *UnsupportedValueError) Error() string
Click to show internal directories.
Click to hide internal directories.