NewClient creates a new client connection using the given net connection. The URL u specifies the host and request URI. Use requestHeader to specify the origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies (Cookie). Use the response.Header to get the selected subprotocol (Sec-WebSocket
(netConn net.Conn, u *url.URL, requestHeader http.Header, readBufSize, writeBufSize int)
| 38 | // |
| 39 | // Deprecated: Use Dialer instead. |
| 40 | func NewClient(netConn net.Conn, u *url.URL, requestHeader http.Header, readBufSize, writeBufSize int) (c *Conn, response *http.Response, err error) { |
| 41 | d := Dialer{ |
| 42 | ReadBufferSize: readBufSize, |
| 43 | WriteBufferSize: writeBufSize, |
| 44 | NetDial: func(net, addr string) (net.Conn, error) { |
| 45 | return netConn, nil |
| 46 | }, |
| 47 | } |
| 48 | return d.Dial(u.String(), requestHeader) |
| 49 | } |
| 50 | |
| 51 | // A Dialer contains options for connecting to WebSocket server. |
| 52 | // |