This repository was archived by the owner on Aug 30, 2024. It is now read-only.
File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,9 @@ func (d *Dialer) Close() error {
176
176
177
177
// Ping sends a ping through the control channel.
178
178
func (d * Dialer ) Ping (ctx context.Context ) error {
179
+ if d .ctrl .ReadyState () == webrtc .DataChannelStateClosed || d .ctrl .ReadyState () == webrtc .DataChannelStateClosing {
180
+ return webrtc .ErrConnectionClosed
181
+ }
179
182
// Since we control the client and server we could open this
180
183
// data channel with `Negotiated` true to reduce traffic being
181
184
// sent when the RTC connection is opened.
Original file line number Diff line number Diff line change @@ -161,6 +161,29 @@ func TestDial(t *testing.T) {
161
161
return
162
162
}
163
163
})
164
+
165
+ t .Run ("Disconnect" , func (t * testing.T ) {
166
+ connectAddr , listenAddr := createDumbBroker (t )
167
+ _ , err := Listen (context .Background (), listenAddr )
168
+ if err != nil {
169
+ t .Error (err )
170
+ return
171
+ }
172
+ dialer , err := DialWebsocket (context .Background (), connectAddr , nil )
173
+ if err != nil {
174
+ t .Error (err )
175
+ return
176
+ }
177
+ err = dialer .Close ()
178
+ if err != nil {
179
+ t .Error (err )
180
+ return
181
+ }
182
+ err = dialer .Ping (context .Background ())
183
+ if err != webrtc .ErrConnectionClosed {
184
+ t .Error (err )
185
+ }
186
+ })
164
187
}
165
188
166
189
func BenchmarkThroughput (b * testing.B ) {
You can’t perform that action at this time.
0 commit comments