diff --git a/controlfloor.go b/controlfloor.go index b75477f..5323568 100644 --- a/controlfloor.go +++ b/controlfloor.go @@ -35,6 +35,7 @@ type ControlFloor struct { DevTracker *DeviceTracker vidConns map[string] *ws.Conn selfSigned bool + delayed bool } func NewControlFloor( config *Config ) (*ControlFloor, chan bool) { @@ -67,6 +68,7 @@ func NewControlFloor( config *Config ) (*ControlFloor, chan bool) { pass: pass, lock: &sync.Mutex{}, vidConns: make( map[string] *ws.Conn ), + delayed: false } if config.https { self.base = "https://" + config.cfHost @@ -88,7 +90,6 @@ func NewControlFloor( config *Config ) (*ControlFloor, chan bool) { go func() { exit := false - delayed := false for { select { case <- stopCf: @@ -108,11 +109,11 @@ func NewControlFloor( config *Config ) (*ControlFloor, chan bool) { fmt.Println("Waiting 10 seconds to retry...") time.Sleep( time.Second * 10 ) fmt.Println("trying again\n") - delayed = true + self.delayed = true continue } - if delayed { + if self.delayed { self.DevTracker.cfReady() } diff --git a/device_tracker.go b/device_tracker.go index 3f1eea6..e221bae 100644 --- a/device_tracker.go +++ b/device_tracker.go @@ -125,6 +125,7 @@ func (self *DeviceTracker) onDeviceConnect1( bdev BridgeDev ) *Device { if !self.cf.ready { self.pendingDevs = append( self.pendingDevs, bdev ) + self.cf.delayed = true fmt.Printf("Device attached, but ControlFloor not ready.\n udid=%s\n", udid ) return nil } @@ -252,4 +253,4 @@ func (self *DeviceTracker) onDeviceConnect( uuid string, bdev BridgeDev ) (*Devi func (self *DeviceTracker) onDeviceDisconnect( dev *Device ) { dev.connected = false -} \ No newline at end of file +}