(ctx context.Context, client *codersdk.Client, url string)
| 270 | } |
| 271 | |
| 272 | func appClientConn(ctx context.Context, client *codersdk.Client, url string) (*countReadWriteCloser, error) { |
| 273 | wsOptions := &websocket.DialOptions{ |
| 274 | HTTPClient: client.HTTPClient, |
| 275 | } |
| 276 | client.SessionTokenProvider.SetDialOption(wsOptions) |
| 277 | |
| 278 | //nolint:bodyclose // The websocket conn manages the body. |
| 279 | conn, _, err := websocket.Dial(ctx, url, wsOptions) |
| 280 | if err != nil { |
| 281 | return nil, xerrors.Errorf("websocket dial: %w", err) |
| 282 | } |
| 283 | |
| 284 | netConn := websocketNetConn(conn, websocket.MessageBinary) |
| 285 | |
| 286 | // Wrap the conn in a countReadWriteCloser so we can monitor bytes sent/rcvd. |
| 287 | crw := &countReadWriteCloser{rwc: netConn} |
| 288 | return crw, nil |
| 289 | } |
| 290 | |
| 291 | // wsNetConn wraps net.Conn created by websocket.NetConn(). Cancel func |
| 292 | // is called if a read or write error is encountered. |
no test coverage detected