func ParseV22Frame(reader io.Reader) Framer { data := make([]byte, V22FrameHeaderSize) if n, err := io.ReadFull(reader, data); n < V22FrameHeaderSize || err != nil { return nil } id := string(data[:3]) t, ok := V22FrameTypeMap[id] if !ok { return nil } size, err := encodedbytes.NormInt(data[3:6]) if err != nil { return nil } h := FrameHead{ FrameType: t, size: size, } frameData := make([]byte, size) if n, err := io.ReadFull(reader, frameData); n < int(size) || err != nil { return nil } return t.constructor(h, frameData) }
func ParseV23Frame(reader io.Reader) Framer { data := make([]byte, FrameHeaderSize) if n, err := io.ReadFull(reader, data); n < FrameHeaderSize || err != nil { return nil } id := string(data[:4]) t, ok := V23FrameTypeMap[id] if !ok { return nil } size, err := encodedbytes.NormInt(data[4:8]) if err != nil { return nil } h := FrameHead{ FrameType: t, statusFlags: data[8], formatFlags: data[9], size: size, } frameData := make([]byte, size) if n, err := io.ReadFull(reader, frameData); n < int(size) || err != nil { return nil } return t.constructor(h, frameData) }