webRTCConn close as part of its reset, instead of depending on external deferred close after receiving reset channel, allows valid disconnections even before use

This commit is contained in:
Serene Han 2016-03-29 22:28:52 -07:00 committed by Arlo Breault
parent bc1a499bc8
commit 1d1882b59d
2 changed files with 3 additions and 3 deletions

View file

@ -291,13 +291,14 @@ func (c *webRTCConn) Reset() {
c.reset <- struct{}{}
log.Println("WebRTC resetting...")
}()
c.Close()
}
func (c *webRTCConn) cleanup() {
if nil != c.snowflake {
s := c.snowflake
log.Printf("WebRTC: closing DataChannel")
// Setting snowflak to nil *before* Close indicates to OnClose that it
// Setting snowflake to nil *before* Close indicates to OnClose that it
// was locally triggered.
c.snowflake = nil
s.Close()