func (codec XHR) Decode(reader io.Reader) (packet.Payload, error) {
	encoded, err := ioutil.ReadAll(reader)

	if err != nil {
		return nil, err
	}

	if len(encoded) == 0 {
		return nil, errors.New("payload is empty")
	}

	if encoded[0] <= 1 {
		return codec.decodeBinaryPayload(encoded)
	}

	return codec.decodeStringPayload(encoded)
}
// Decode decodes payload of packets
Decode decodes payload of packets
// Decode decodes payload of packets
func (codec XHR) Decode(reader io.Reader) (packet.Payload, error) {
	encoded, err := ioutil.ReadAll(reader)
	if err != nil {
		return nil, err
	}
	if len(encoded) == 0 {
		return nil, errors.New("payload is empty")
	}
	if encoded[0] <= 1 {
		return codec.decodeBinaryPayload(encoded)
	}
	return codec.decodeStringPayload(encoded)
}
func ( codec XHR ) Decode ( reader io . Reader ) ( packet . Payload , error ) { encoded , err := ioutil . ReadAll ( reader ) if err != nil { return nil , err } if len ( encoded ) == 0 { return nil , errors . New ( " " ) } if encoded [ 0 ] <= 1 { return codec . decodeBinaryPayload ( encoded ) } return codec . decodeStringPayload ( encoded ) }
Decode decodes payload of packets
Decode decodes payload of packets