good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit ba35516b authored by Anmol Sethi's avatar Anmol Sethi
Browse files

Doc fixes

parent ee1fed81
Branches
Tags
No related merge requests found
...@@ -20,11 +20,11 @@ go get nhooyr.io/websocket ...@@ -20,11 +20,11 @@ go get nhooyr.io/websocket
- JSON and protobuf helpers in the [wsjson](https://pkg.go.dev/nhooyr.io/websocket/wsjson) and [wspb](https://pkg.go.dev/nhooyr.io/websocket/wspb) subpackages - JSON and protobuf helpers in the [wsjson](https://pkg.go.dev/nhooyr.io/websocket/wsjson) and [wspb](https://pkg.go.dev/nhooyr.io/websocket/wspb) subpackages
- Zero alloc reads and writes - Zero alloc reads and writes
- Concurrent writes - Concurrent writes
- [Close handshake](https://godoc.org/nhooyr.io/websocket#Conn.Close) - [Close handshake](https://pkg.go.dev/nhooyr.io/websocket#Conn.Close)
- [net.Conn](https://godoc.org/nhooyr.io/websocket#NetConn) wrapper - [net.Conn](https://pkg.go.dev/nhooyr.io/websocket#NetConn) wrapper
- [Ping pong](https://godoc.org/nhooyr.io/websocket#Conn.Ping) API - [Ping pong](https://pkg.go.dev/nhooyr.io/websocket#Conn.Ping) API
- [RFC 7692](https://tools.ietf.org/html/rfc7692) permessage-deflate compression - [RFC 7692](https://tools.ietf.org/html/rfc7692) permessage-deflate compression
- Compile to [Wasm](https://godoc.org/nhooyr.io/websocket#hdr-Wasm) - Compile to [Wasm](https://pkg.go.dev/nhooyr.io/websocket#hdr-Wasm)
## Roadmap ## Roadmap
...@@ -89,14 +89,14 @@ c.Close(websocket.StatusNormalClosure, "") ...@@ -89,14 +89,14 @@ c.Close(websocket.StatusNormalClosure, "")
Advantages of [gorilla/websocket](https://github.com/gorilla/websocket): Advantages of [gorilla/websocket](https://github.com/gorilla/websocket):
- Mature and widely used - Mature and widely used
- [Prepared writes](https://godoc.org/github.com/gorilla/websocket#PreparedMessage) - [Prepared writes](https://pkg.go.dev/github.com/gorilla/websocket#PreparedMessage)
- Configurable [buffer sizes](https://godoc.org/github.com/gorilla/websocket#hdr-Buffers) - Configurable [buffer sizes](https://pkg.go.dev/github.com/gorilla/websocket#hdr-Buffers)
Advantages of nhooyr.io/websocket: Advantages of nhooyr.io/websocket:
- Minimal and idiomatic API - Minimal and idiomatic API
- Compare godoc of [nhooyr.io/websocket](https://godoc.org/nhooyr.io/websocket) with [gorilla/websocket](https://godoc.org/github.com/gorilla/websocket) side by side. - Compare godoc of [nhooyr.io/websocket](https://pkg.go.dev/nhooyr.io/websocket) with [gorilla/websocket](https://pkg.go.dev/github.com/gorilla/websocket) side by side.
- [net.Conn](https://godoc.org/nhooyr.io/websocket#NetConn) wrapper - [net.Conn](https://pkg.go.dev/nhooyr.io/websocket#NetConn) wrapper
- Zero alloc reads and writes ([gorilla/websocket#535](https://github.com/gorilla/websocket/issues/535)) - Zero alloc reads and writes ([gorilla/websocket#535](https://github.com/gorilla/websocket/issues/535))
- Full [context.Context](https://blog.golang.org/context) support - Full [context.Context](https://blog.golang.org/context) support
- Dial uses [net/http.Client](https://golang.org/pkg/net/http/#Client) - Dial uses [net/http.Client](https://golang.org/pkg/net/http/#Client)
...@@ -104,24 +104,24 @@ Advantages of nhooyr.io/websocket: ...@@ -104,24 +104,24 @@ Advantages of nhooyr.io/websocket:
- Gorilla writes directly to a net.Conn and so duplicates features of net/http.Client. - Gorilla writes directly to a net.Conn and so duplicates features of net/http.Client.
- Concurrent writes - Concurrent writes
- Close handshake ([gorilla/websocket#448](https://github.com/gorilla/websocket/issues/448)) - Close handshake ([gorilla/websocket#448](https://github.com/gorilla/websocket/issues/448))
- Idiomatic [ping pong](https://godoc.org/nhooyr.io/websocket#Conn.Ping) API - Idiomatic [ping pong](https://pkg.go.dev/nhooyr.io/websocket#Conn.Ping) API
- Gorilla requires registering a pong callback before sending a Ping - Gorilla requires registering a pong callback before sending a Ping
- Can target Wasm ([gorilla/websocket#432](https://github.com/gorilla/websocket/issues/432)) - Can target Wasm ([gorilla/websocket#432](https://github.com/gorilla/websocket/issues/432))
- Transparent message buffer reuse with [wsjson](https://godoc.org/nhooyr.io/websocket/wsjson) and [wspb](https://godoc.org/nhooyr.io/websocket/wspb) subpackages - Transparent message buffer reuse with [wsjson](https://pkg.go.dev/nhooyr.io/websocket/wsjson) and [wspb](https://pkg.go.dev/nhooyr.io/websocket/wspb) subpackages
- [1.75x](https://github.com/nhooyr/websocket/releases/tag/v1.7.4) faster WebSocket masking implementation in pure Go - [1.75x](https://github.com/nhooyr/websocket/releases/tag/v1.7.4) faster WebSocket masking implementation in pure Go
- Gorilla's implementation is slower and uses [unsafe](https://golang.org/pkg/unsafe/). - Gorilla's implementation is slower and uses [unsafe](https://golang.org/pkg/unsafe/).
- Full [permessage-deflate](https://tools.ietf.org/html/rfc7692) compression extension support - Full [permessage-deflate](https://tools.ietf.org/html/rfc7692) compression extension support
- Gorilla only supports no context takeover mode - Gorilla only supports no context takeover mode
- We use a vendored [klauspost/compress](https://github.com/klauspost/compress) for much lower memory usage ([gorilla/websocket#203](https://github.com/gorilla/websocket/issues/203)) - We use a vendored [klauspost/compress](https://github.com/klauspost/compress) for much lower memory usage ([gorilla/websocket#203](https://github.com/gorilla/websocket/issues/203))
- [CloseRead](https://godoc.org/nhooyr.io/websocket#Conn.CloseRead) helper ([gorilla/websocket#492](https://github.com/gorilla/websocket/issues/492)) - [CloseRead](https://pkg.go.dev/nhooyr.io/websocket#Conn.CloseRead) helper ([gorilla/websocket#492](https://github.com/gorilla/websocket/issues/492))
- Actively maintained ([gorilla/websocket#370](https://github.com/gorilla/websocket/issues/370)) - Actively maintained ([gorilla/websocket#370](https://github.com/gorilla/websocket/issues/370))
#### golang.org/x/net/websocket #### golang.org/x/net/websocket
[golang.org/x/net/websocket](https://godoc.org/golang.org/x/net/websocket) is deprecated. [golang.org/x/net/websocket](https://pkg.go.dev/golang.org/x/net/websocket) is deprecated.
See [golang/go/issues/18152](https://github.com/golang/go/issues/18152). See [golang/go/issues/18152](https://github.com/golang/go/issues/18152).
The [net.Conn](https://godoc.org/nhooyr.io/websocket#NetConn) can help in transitioning The [net.Conn](https://pkg.go.dev/nhooyr.io/websocket#NetConn) can help in transitioning
to nhooyr.io/websocket. to nhooyr.io/websocket.
#### gobwas/ws #### gobwas/ws
......
...@@ -63,6 +63,7 @@ func (c *Conn) writeClose(code StatusCode, reason string) error { ...@@ -63,6 +63,7 @@ func (c *Conn) writeClose(code StatusCode, reason string) error {
Reason: reason, Reason: reason,
} }
// TODO one problem with this is that if the connection is actually closed in the meantime, the error returned below will be this one lol.
c.setCloseErr(fmt.Errorf("sent close frame: %w", ce)) c.setCloseErr(fmt.Errorf("sent close frame: %w", ce))
var p []byte var p []byte
......
...@@ -59,7 +59,7 @@ type DialOptions struct { ...@@ -59,7 +59,7 @@ type DialOptions struct {
// in net/http to perform WebSocket handshakes. // in net/http to perform WebSocket handshakes.
// See docs on the HTTPClient option and https://github.com/golang/go/issues/26937#issuecomment-415855861 // See docs on the HTTPClient option and https://github.com/golang/go/issues/26937#issuecomment-415855861
// //
// URLs with http/https schemes will work and translated into ws/wss. // URLs with http/https schemes will work and are interpreted as ws/wss.
func Dial(ctx context.Context, u string, opts *DialOptions) (*Conn, *http.Response, error) { func Dial(ctx context.Context, u string, opts *DialOptions) (*Conn, *http.Response, error) {
return dial(ctx, u, opts, nil) return dial(ctx, u, opts, nil)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment