Skip to content

Commit 4b724ae

Browse files
committed
Rewrite websocket.go to remove writeLoop and simplify readLoop
Closes #79 Closes #73
1 parent e9dfcc4 commit 4b724ae

File tree

4 files changed

+297
-283
lines changed

4 files changed

+297
-283
lines changed

accept.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func verifyClientRequest(w http.ResponseWriter, r *http.Request) error {
7575

7676
// Accept accepts a WebSocket handshake from a client and upgrades the
7777
// the connection to WebSocket.
78+
//
7879
// Accept will reject the handshake if the Origin domain is not the same as the Host unless
7980
// the InsecureSkipVerify option is set.
8081
func Accept(w http.ResponseWriter, r *http.Request, opts AcceptOptions) (*Conn, error) {
@@ -132,6 +133,8 @@ func accept(w http.ResponseWriter, r *http.Request, opts AcceptOptions) (*Conn,
132133
closer: netConn,
133134
}
134135
c.init()
136+
// TODO document.
137+
c.Context(r.Context())
135138

136139
return c, nil
137140
}

ci/lint/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ source ci/lib.sh || exit 1
77
shellcheck ./**/*.sh
88
)
99

10-
go vet -composites=false ./...
10+
go vet -composites=false -lostcancel=false ./...
1111
go run golang.org/x/lint/golint -set_exit_status ./...

export_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ import (
1414
// exceeds the buffer size which is 4096 right now as then an extra syscall
1515
// will be necessary to complete the message.
1616
func (c *Conn) Write(ctx context.Context, typ MessageType, p []byte) error {
17-
return c.writeSingleFrame(ctx, opcode(typ), p)
17+
return c.writeCompleteMessage(ctx, opcode(typ), p)
1818
}

0 commit comments

Comments
 (0)