11# websocket
22
3- [ ![ version ] ( https://img.shields.io/github/v/release/nhooyr/websocket?color=6b9ded&sort=semver )] ( https://github.com/nhooyr/websocket/releases )
4- [ ![ docs ] ( https://godoc.org/nhooyr.io/websocket?status.svg )] ( https://godoc.org/nhooyr.io/websocket )
3+ [ ![ release ] ( https://img.shields.io/github/v/release/nhooyr/websocket?color=6b9ded&sort=semver )] ( https://github.com/nhooyr/websocket/releases )
4+ [ ![ godoc ] ( https://godoc.org/nhooyr.io/websocket?status.svg )] ( https://godoc.org/nhooyr.io/websocket )
55[ ![ coverage] ( https://img.shields.io/coveralls/github/nhooyr/websocket?color=65d6a4 )] ( https://coveralls.io/github/nhooyr/websocket )
66[ ![ ci] ( https://github.com/nhooyr/websocket/workflows/ci/badge.svg )] ( https://github.com/nhooyr/websocket/actions )
77
@@ -19,14 +19,14 @@ go get nhooyr.io/websocket
1919- First class [ context.Context] ( https://blog.golang.org/context ) support
2020- Thorough tests, fully passes the [ autobahn-testsuite] ( https://github.com/crossbario/autobahn-testsuite )
2121- [ Zero dependencies] ( https://godoc.org/nhooyr.io/websocket?imports )
22- - JSON and ProtoBuf helpers in the [ wsjson] ( https://godoc.org/nhooyr.io/websocket/wsjson ) and [ wspb] ( https://godoc.org/nhooyr.io/websocket/wspb ) subpackages
22+ - JSON and protobuf helpers in the [ wsjson] ( https://godoc.org/nhooyr.io/websocket/wsjson ) and [ wspb] ( https://godoc.org/nhooyr.io/websocket/wspb ) subpackages
2323- Zero alloc reads and writes
2424- Concurrent writes
2525- [ Close handshake] ( https://godoc.org/nhooyr.io/websocket#Conn.Close )
2626- [ net.Conn] ( https://godoc.org/nhooyr.io/websocket#NetConn ) wrapper
27- - [ Ping pong] ( https://godoc.org/nhooyr.io/websocket#Conn.Ping )
27+ - [ Ping pong] ( https://godoc.org/nhooyr.io/websocket#Conn.Ping ) API
2828- [ RFC 7692] ( https://tools.ietf.org/html/rfc7692 ) permessage-deflate compression
29- - Compile to [ Wasm] ( https://godoc.org/nhooyr.io/websocket#hdr-Wasm )
29+ - Can target [ Wasm] ( https://godoc.org/nhooyr.io/websocket#hdr-Wasm )
3030
3131## Roadmap
3232
@@ -85,7 +85,11 @@ c.Close(websocket.StatusNormalClosure, "")
8585
8686### gorilla/websocket
8787
88- [ gorilla/websocket] ( https://github.com/gorilla/websocket ) is a widely used and mature library.
88+ Advantages of [ gorilla/websocket] ( https://github.com/gorilla/websocket ) :
89+
90+ - Mature and widely used
91+ - [ Prepared writes] ( https://godoc.org/github.com/gorilla/websocket#PreparedMessage )
92+ - Configurable [ buffer sizes] ( https://godoc.org/github.com/gorilla/websocket#hdr-Buffers )
8993
9094Advantages of nhooyr.io/websocket:
9195
@@ -94,26 +98,26 @@ Advantages of nhooyr.io/websocket:
9498- [ net.Conn] ( https://godoc.org/nhooyr.io/websocket#NetConn ) wrapper
9599- Zero alloc reads and writes ([ gorilla/websocket #535 ] ( https://github.com/gorilla/websocket/issues/535 ) )
96100- Full [ context.Context] ( https://blog.golang.org/context ) support
97- - Uses [ net/http.Client] ( https://golang.org/pkg/net/http/#Client ) for dialing
101+ - Dial uses [ net/http.Client] ( https://golang.org/pkg/net/http/#Client )
98102 - Will enable easy HTTP/2 support in the future
99- - Gorilla writes directly to a net.Conn and so duplicates features from net/http.Client.
103+ - Gorilla writes directly to a net.Conn and so duplicates features of net/http.Client.
100104- Concurrent writes
101105- Close handshake ([ gorilla/websocket #448 ] ( https://github.com/gorilla/websocket/issues/448 ) )
102- - Idiomatic [ ping] ( https://godoc.org/nhooyr.io/websocket#Conn.Ping ) API
103- - gorilla/websocket requires registering a pong callback and then sending a Ping
104- - Wasm ([ gorilla/websocket #432 ] ( https://github.com/gorilla/websocket/issues/432 ) )
106+ - Idiomatic [ ping pong ] ( https://godoc.org/nhooyr.io/websocket#Conn.Ping ) API
107+ - Gorilla requires registering a pong callback before sending a Ping
108+ - Can target Wasm ([ gorilla/websocket #432 ] ( https://github.com/gorilla/websocket/issues/432 ) )
105109- Transparent message buffer reuse with [ wsjson] ( https://godoc.org/nhooyr.io/websocket/wsjson ) and [ wspb] ( https://godoc.org/nhooyr.io/websocket/wspb ) subpackages
106110- [ 1.75x] ( https://github.com/nhooyr/websocket/releases/tag/v1.7.4 ) faster WebSocket masking implementation in pure Go
107- - Gorilla's implementation depends on unsafe and is slower
111+ - Gorilla's implementation is slower and uses [ unsafe ] ( https://golang.org/pkg/unsafe/ ) .
108112- Full [ permessage-deflate] ( https://tools.ietf.org/html/rfc7692 ) compression extension support
109113 - Gorilla only supports no context takeover mode
110- - [ CloseRead] ( https://godoc.org/nhooyr.io/websocket#Conn.CloseRead ) helper
114+ - [ CloseRead] ( https://godoc.org/nhooyr.io/websocket#Conn.CloseRead ) helper ( [ gorilla/websocket # 492 ] ( https://github.com/gorilla/websocket/issues/492 ) )
111115- Actively maintained ([ gorilla/websocket #370 ] ( https://github.com/gorilla/websocket/issues/370 ) )
112116
113117#### golang.org/x/net/websocket
114118
115119[ golang.org/x/net/websocket] ( https://godoc.org/golang.org/x/net/websocket ) is deprecated.
116- See ( [ golang/go/issues/18152] ( https://github.com/golang/go/issues/18152 ) ).
120+ See [ golang/go/issues/18152] ( https://github.com/golang/go/issues/18152 ) .
117121
118122The [ net.Conn] ( https://godoc.org/nhooyr.io/websocket#NetConn ) wrapper will ease in transitioning
119123to nhooyr.io/websocket.
@@ -124,10 +128,3 @@ to nhooyr.io/websocket.
124128in an event driven style for performance. See the author's [ blog post] ( https://medium.freecodecamp.org/million-websockets-and-go-cc58418460bb ) .
125129
126130However when writing idiomatic Go, nhooyr.io/websocket will be faster and easier to use.
127-
128- ## Users
129-
130- If your company or project is using this library, feel free to open an issue or PR to amend this list.
131-
132- - [ Coder] ( https://github.com/cdr )
133- - [ Tatsu Works] ( https://github.com/tatsuworks ) - Ingresses 20 TB in WebSocket data every month on their Discord bot.
0 commit comments