Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 45cae5a

Browse files
authored
fix: Remove unused context from RTC Dial (#336)
* fix: Remove unused context from Dial * Ignore read/write on closed pipe
1 parent 16ca4a6 commit 45cae5a

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

wsnet/dial.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ func DialWebsocket(ctx context.Context, broker string, iceServers []webrtc.ICESe
3636
// We should close the socket intentionally.
3737
_ = conn.Close(websocket.StatusInternalError, "an error occurred")
3838
}()
39-
return Dial(ctx, nconn, iceServers)
39+
return Dial(nconn, iceServers)
4040
}
4141

4242
// Dial negotiates a connection to a listener.
43-
func Dial(ctx context.Context, conn net.Conn, iceServers []webrtc.ICEServer) (*Dialer, error) {
43+
func Dial(conn net.Conn, iceServers []webrtc.ICEServer) (*Dialer, error) {
4444
if iceServers == nil {
4545
iceServers = []webrtc.ICEServer{}
4646
}
@@ -129,11 +129,7 @@ func (d *Dialer) negotiate() (err error) {
129129
for {
130130
var msg protoMessage
131131
err = decoder.Decode(&msg)
132-
if errors.Is(err, io.EOF) {
133-
break
134-
}
135-
if websocket.CloseStatus(err) == websocket.StatusNormalClosure {
136-
// The listener closed the socket because success!
132+
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrClosedPipe) {
137133
break
138134
}
139135
if err != nil {

0 commit comments

Comments
 (0)