func (c *Conn) WriteBody(b []byte) (err error) {
	if len(b) > 0 {
		_, err = c.w.Write(b)
	}
	return
}
WriteBody write a message body.
package websocket
import (
	"encoding/binary"
	"errors"
	"fmt"
	"io"
	"github.com/tsingson/ex-goim/pkg/bufio"
)
const (
	finBit  = 1 << 7
	rsv1Bit = 1 << 6
	rsv2Bit = 1 << 5
	rsv3Bit = 1 << 4
	opBit   = 0x0f
	maskBit = 1 << 7
	lenBit  = 0x7f
	continuationFrame        = 0
	continuationFrameMaxRead = 100
)
const (
	TextMessage = 1
	BinaryMessage = 2
	CloseMessage = 8
	PingMessage = 9
	PongMessage = 10
)
var (
	ErrMessageClose = errors.New("close control message")
	ErrMessageMaxRead = errors.New("continuation frame max read")
)
type Conn struct {
	rwc io.ReadWriteCloser
	r   *bufio.Reader
	w   *bufio.Writer
}
func newConn(rwc io.ReadWriteCloser, r *bufio.Reader, w *bufio.Writer) *Conn {
	return &Conn{rwc: rwc, r: r, w: w}
}
func (c *Conn) WriteMessage(msgType int, msg []byte) (err error) {
	if err = c.WriteHeader(msgType, len(msg)); err != nil {
		return
	}
	err = c.WriteBody(msg)
	return
}
func (c *Conn) WriteHeader(msgType int, length int) (err error) {
	var h []byte
	if h, err = c.w.Peek(2); err != nil {
		return
	}
	h[0] = 0
	h[0] |= finBit | byte(msgType)
	h[1] = 0
	switch {
	case length <= 125:
		h[1] |= byte(length)
	case length < 65536:
		h[1] |= 126
		if h, err = c.w.Peek(2); err != nil {
			return
		}
		binary.BigEndian.PutUint16(h, uint16(length))
	default:
		h[1] |= 127
		if h, err = c.w.Peek(8); err != nil {
			return
		}
		binary.BigEndian.PutUint64(h, uint64(length))
	}
	return
}