Skip to content

Commit

Permalink
Moved data channel timeout to constant
Browse files Browse the repository at this point in the history
  • Loading branch information
cohosh committed Apr 5, 2019
1 parent 08f5205 commit 62fddab
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion proxy-go/snowflake.go
Expand Up @@ -26,6 +26,9 @@ const defaultBrokerURL = "https://snowflake-broker.bamsoftware.com/"
const defaultRelayURL = "wss://snowflake.bamsoftware.com/"
const defaultSTUNURL = "stun:stun.l.google.com:19302"
const pollInterval = 5 * time.Second
//amount of time after sending an SDP answer before the proxy assumes the
//client is not going to connect
const dataChannelTimeout = time.Minute

var brokerURL *url.URL
var relayURL string
Expand Down Expand Up @@ -330,7 +333,7 @@ func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription, config *webrtc.
// advanced to PeerConnectionStateConnected in this time,
// destroy the peer connection and return the token.
go func() {
<-time.After(time.Minute)
<-time.After(dataChannelTimeout)
if pc.ConnectionState() != webrtc.PeerConnectionStateConnected {
log.Println("Timed out waiting for client to open data cannel.")
pc.Destroy()
Expand Down

0 comments on commit 62fddab

Please sign in to comment.