func (c *websocketConnector) SetDeadline(t time.Time) error {
	if err := c.SetReadDeadline(t); err != nil {
		return err
	}
	err := c.SetWriteDeadline(t)
	return err
}
SetDeadline sets both the read and write deadlines
package mqtt
import (
	"crypto/tls"
	"fmt"
	"io"
	"net"
	"net/http"
	"net/url"
	"sync"
	"time"
	"github.com/gorilla/websocket"
)
type WebsocketOptions struct {
	ReadBufferSize  int
	WriteBufferSize int
	Proxy           ProxyFunction
}
type ProxyFunction func(req *http.Request) (*url.URL, error)
func NewWebsocket(host string, tlsc *tls.Config, timeout time.Duration, requestHeader http.Header, options *WebsocketOptions) (net.Conn, error) {
	if timeout == 0 {
		timeout = 10 * time.Second
	}
	if options == nil {
		options = &WebsocketOptions{}
	}
	if options.Proxy == nil {
		options.Proxy = http.ProxyFromEnvironment
	}
	dialer := &websocket.Dialer{
		Proxy:             options.Proxy,
		HandshakeTimeout:  timeout,
		EnableCompression: false,
		TLSClientConfig:   tlsc,
		Subprotocols:      []string{"mqtt"},
		ReadBufferSize:    options.ReadBufferSize,
		WriteBufferSize:   options.WriteBufferSize,
	}
	ws, resp, err := dialer.Dial(host, requestHeader)
	if err != nil {
		if resp != nil {
			WARN.Println(CLI, fmt.Sprintf("Websocket handshake failure. StatusCode: %d. Body: %s", resp.StatusCode, resp.Body))
		}
		return nil, err
	}
	wrapper := &websocketConnector{
		Conn: ws,
	}
	return wrapper, err
}
type websocketConnector struct {
	*websocket.Conn
	r   io.Reader
	rio sync.Mutex
	wio sync.Mutex
}