Skip to content

Commit b74c66b

Browse files
authored
Merge pull request #160 from nhooyr/close
Implement complete close handshake
2 parents e795e46 + 9703ba2 commit b74c66b

11 files changed

+274
-172
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ on: [push]
44
jobs:
55
fmt:
66
runs-on: ubuntu-latest
7-
container: nhooyr/websocket-ci@sha256:f8b6e53a9fd256bcf6c90029276385b9ec730b76a0d7ccf3ff19084bce210c50
7+
container: nhooyr/websocket-ci@sha256:13f9b8cc2f901e98c253595c4070254ece08543f6e100b4fa6682f87de4388eb
88
steps:
99
- uses: actions/checkout@v1
1010
- run: yarn --frozen-lockfile && yarn fmt
1111
lint:
1212
runs-on: ubuntu-latest
13-
container: nhooyr/websocket-ci@sha256:f8b6e53a9fd256bcf6c90029276385b9ec730b76a0d7ccf3ff19084bce210c50
13+
container: nhooyr/websocket-ci@sha256:13f9b8cc2f901e98c253595c4070254ece08543f6e100b4fa6682f87de4388eb
1414
steps:
1515
- uses: actions/checkout@v1
1616
- run: yarn --frozen-lockfile && yarn lint
1717
test:
1818
runs-on: ubuntu-latest
19-
container: nhooyr/websocket-ci@sha256:f8b6e53a9fd256bcf6c90029276385b9ec730b76a0d7ccf3ff19084bce210c50
19+
container: nhooyr/websocket-ci@sha256:13f9b8cc2f901e98c253595c4070254ece08543f6e100b4fa6682f87de4388eb
2020
steps:
2121
- uses: actions/checkout@v1
2222
- run: yarn --frozen-lockfile && yarn test

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ go get nhooyr.io/websocket
2424
- Highly optimized by default
2525
- Concurrent writes out of the box
2626
- [Complete Wasm](https://godoc.org/nhooyr.io/websocket#hdr-Wasm) support
27+
- [Close handshake](https://godoc.org/nhooyr.io/websocket#Conn.Close)
2728

2829
## Roadmap
2930

@@ -128,7 +129,9 @@ gorilla/websocket writes its handshakes to the underlying net.Conn.
128129
Thus it has to reinvent hooks for TLS and proxies and prevents support of HTTP/2.
129130

130131
Some more advantages of nhooyr.io/websocket are that it supports concurrent writes and
131-
makes it very easy to close the connection with a status code and reason.
132+
makes it very easy to close the connection with a status code and reason. In fact,
133+
nhooyr.io/websocket even implements the complete WebSocket close handshake for you whereas
134+
with gorilla/websocket you have to perform it manually. See [gorilla/websocket#448](https://github.com/gorilla/websocket/issues/448).
132135

133136
The ping API is also nicer. gorilla/websocket requires registering a pong handler on the Conn
134137
which results in awkward control flow. With nhooyr.io/websocket you use the Ping method on the Conn

ci/test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if (require.main === module) {
1111
}
1212

1313
export async function test(ctx: Promise<unknown>) {
14-
const args = ["-parallel=1024", "-coverprofile=ci/out/coverage.prof", "-coverpkg=./..."]
14+
const args = ["-parallel=32", "-coverprofile=ci/out/coverage.prof", "-coverpkg=./..."]
1515

1616
if (process.env.CI) {
1717
args.push("-race")

0 commit comments

Comments
 (0)