func (codec XHR) Encode(payload packet.Payload, writer io.Writer) error {
	if len(payload) == 0 {
		return nil
	}

	binary := !codec.ForceBase64 && payload.ContainsBinary()

	for _, packet := range payload {
		var err error

		if binary {
			err = codec.encodeBinaryPacket(packet, writer)
		} else {
			err = codec.encodeStringPacket(packet, writer)
		}

		if err != nil {
			return err
		}
	}

	return nil
}
// Encode encodes payload of packets for single poll
Encode encodes payload of packets for single poll
// Encode encodes payload of packets for single poll
func (codec XHR) Encode(payload packet.Payload, writer io.Writer) error {
	if len(payload) == 0 {
		return nil
	}
	binary := !codec.ForceBase64 && payload.ContainsBinary()
	for _, packet := range payload {
		var err error
		if binary {
			err = codec.encodeBinaryPacket(packet, writer)
		} else {
			err = codec.encodeStringPacket(packet, writer)
		}
		if err != nil {
			return err
		}
	}
	return nil
}
func ( codec XHR ) Encode ( payload packet . Payload , writer io . Writer ) error { if len ( payload ) == 0 { return nil } binary := ! codec . ForceBase64 && payload . ContainsBinary ( ) for _ , packet := range payload { var err error if binary { err = codec . encodeBinaryPacket ( packet , writer ) } else { err = codec . encodeStringPacket ( packet , writer ) } if err != nil { return err } } return nil }
Encode encodes payload of packets for single poll
Encode encodes payload of packets for single poll