Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-ws-transport
Commits
f162b052
Commit
f162b052
authored
Sep 26, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: close gracefully
If we send no message, the client gets a 1005. This will send a 1000.
parent
8cca0dbc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
conn.go
conn.go
+5
-1
No files found.
conn.go
View file @
f162b052
...
...
@@ -84,7 +84,11 @@ func (c *Conn) Write(b []byte) (n int, err error) {
func
(
c
*
Conn
)
Close
()
error
{
var
err
error
c
.
closeOnce
.
Do
(
func
()
{
err1
:=
c
.
Conn
.
WriteControl
(
ws
.
CloseMessage
,
nil
,
time
.
Now
()
.
Add
(
GracefulCloseTimeout
))
err1
:=
c
.
Conn
.
WriteControl
(
ws
.
CloseMessage
,
ws
.
FormatCloseMessage
(
ws
.
CloseNormalClosure
,
"closed"
),
time
.
Now
()
.
Add
(
GracefulCloseTimeout
),
)
err2
:=
c
.
Conn
.
Close
()
switch
{
case
err1
!=
nil
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment