func (c *ClientHandshaker) sendC0C1(writer WriteFlusher) ([]byte, error) {
	var c0c1 [1537]byte
	c0c1[0] = Version3
	_, err := c.randomNumberGenerator(c0c1[1:])
	if err != nil {
		return nil, err
	}
	_, err = writer.Write(c0c1[:])
	if err != nil {
		return nil, err
	}
	err = writer.Flush()
	if err != nil {
		return nil, err
	}
	return c0c1[1:], nil
}
sendC0C1 writes C0 + C1 messages to writer and returns the C1 message that was written.
package rtmp
import (
	"bytes"
	"errors"
	"io"
)
const Version3 = 3
var ErrUnsupportedVersion = errors.New("unsupported rtmp version")
var ErrS2DoesNotMatchC1 = errors.New("s2 message sent by server does not match c1 message sent by client")
var ErrC2DoesNotMatchS1 = errors.New("c2 message sent by client does not match s1 message sent by server")
type Handshaker interface {
	Handshake(reader io.Reader, writer WriteFlusher) error
}
type ClientHandshaker struct {
	Handshaker
	randomNumberGenerator func([]byte) (int, error)
}
func NewClientHandshaker(randomNumberGenerator func([]byte) (int, error)) *ClientHandshaker {
	return &ClientHandshaker{
		randomNumberGenerator: randomNumberGenerator,
	}
}
func (c *ClientHandshaker) Handshake(reader io.Reader, writer WriteFlusher) error {
	c1, err := c.sendC0C1(writer)
	if err != nil {
		return err
	}
	s1, s2, err := c.readS0S1S2(reader)
	if err != nil {
		return err
	}
	if bytes.Compare(c1, s2) != 0 {
		return ErrS2DoesNotMatchC1
	}
	err = c.sendC2(writer, s1)
	return err
}