You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- 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
defer c.Close(websocket.StatusInternalError, "the sky is falling")
86
+
defer c.CloseNow()
82
87
83
88
err = wsjson.Write(ctx, c, "hi")
84
89
if err != nil {
@@ -113,14 +118,13 @@ Advantages of nhooyr.io/websocket:
113
118
- Idiomatic [ping pong](https://pkg.go.dev/nhooyr.io/websocket#Conn.Ping) API
114
119
- Gorilla requires registering a pong callback before sending a Ping
115
120
- Can target Wasm ([gorilla/websocket#432](https://github.com/gorilla/websocket/issues/432))
116
-
- 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
121
+
- Transparent message buffer reuse with [wsjson](https://pkg.go.dev/nhooyr.io/websocket/wsjson)subpackage
117
122
-[1.75x](https://github.com/nhooyr/websocket/releases/tag/v1.7.4) faster WebSocket masking implementation in pure Go
118
123
- Gorilla's implementation is slower and uses [unsafe](https://golang.org/pkg/unsafe/).
124
+
Soon we'll have assembly and be 3x faster [#326](https://github.com/nhooyr/websocket/pull/326)
119
125
- Full [permessage-deflate](https://tools.ietf.org/html/rfc7692) compression extension support
120
126
- Gorilla only supports no context takeover mode
121
-
- We use [klauspost/compress](https://github.com/klauspost/compress) for much lower memory usage ([gorilla/websocket#203](https://github.com/gorilla/websocket/issues/203))
-[CloseRead](https://pkg.go.dev/nhooyr.io/websocket#Conn.CloseRead) helper for write only connections ([gorilla/websocket#492](https://github.com/gorilla/websocket/issues/492))
124
128
125
129
#### golang.org/x/net/websocket
126
130
@@ -135,4 +139,15 @@ to nhooyr.io/websocket.
135
139
[gobwas/ws](https://github.com/gobwas/ws) has an extremely flexible API that allows it to be used
136
140
in an event driven style for performance. See the author's [blog post](https://medium.freecodecamp.org/million-websockets-and-go-cc58418460bb).
137
141
138
-
However when writing idiomatic Go, nhooyr.io/websocket will be faster and easier to use.
142
+
However it is quite bloated. See https://pkg.go.dev/github.com/gobwas/ws
143
+
144
+
When writing idiomatic Go, nhooyr.io/websocket will be faster and easier to use.
145
+
146
+
#### lesismal/nbio
147
+
148
+
[lesismal/nbio](https://github.com/lesismal/nbio) is similar to gobwas/ws in that the API is
149
+
event driven for performance reasons.
150
+
151
+
However it is quite bloated. See https://pkg.go.dev/github.com/lesismal/nbio
152
+
153
+
When writing idiomatic Go, nhooyr.io/websocket will be faster and easier to use.
0 commit comments