Run parts of data channel closure depending on state.

master
Icedream 2019-07-11 14:50:57 +02:00
parent 6f5b605ea7
commit 0fb483d493
Signed by: icedream
GPG Key ID: 1573F6D8EFE4D0CF
1 changed files with 7 additions and 6 deletions

View File

@ -53,14 +53,15 @@ func (conn *DataChannel) OnError(f func(error)) {
func (conn *DataChannel) Close() { func (conn *DataChannel) Close() {
// already closed? // already closed?
if conn.dataChannel.ReadyState() == webrtc.DataChannelStateClosing || if conn.dataChannel.ReadyState() != webrtc.DataChannelStateClosing &&
conn.dataChannel.ReadyState() == webrtc.DataChannelStateClosed { conn.dataChannel.ReadyState() != webrtc.DataChannelStateClosed {
return conn.AbortRawDataTransmission(io.EOF)
conn.dataChannel.Close()
} }
conn.AbortRawDataTransmission(io.EOF) if conn.dataChannel.ReadyState() != webrtc.DataChannelStateClosed {
conn.dataChannel.Close() <-conn.closeWaitChannel
<-conn.closeWaitChannel }
} }
func (conn *DataChannel) triggerOpen() { func (conn *DataChannel) triggerOpen() {