             }
         }
         
-        debugPrint("BP " + formatter.string(from: Date.init()) + " - " + str)
+        print("BP " + formatter.string(from: Date.init()) + " - " + str)
     #endif
 }
 

    var announced = false
    open var keepaliveTimer: Timer?
    open var lastReceivedData: Date = Date.init(timeIntervalSince1970: 0)
}

@objc public protocol BluepeerMembershipRosterDelegate {

            peer.announced = true
        }
        
        peer.connectBlock = {
            do {
                // pick the address to connect to INSIDE the block, because more addresses may have been added between announcement and inviteBlock being executed
                guard let hhaddresses = peer.dnsService?.resolvedAddressInfo, hhaddresses.count > 0, var chosenAddress = hhaddresses.filter({ $0.isCandidateAddress(bluetoothOnly: limitToBluetooth) }).first else {
                    DLog("BluepeerObject inviteBlock: no resolvedAddresses or candidates after invite accepted/rejected, BAILING")
                    return
                }
                
                // if we can use wifi, then use wifi if possible
                if !self.bluetoothOnly && !chosenAddress.isWifiInterface() {
                    let wifiCandidates = hhaddresses.filter({ $0.isCandidateAddress(bluetoothOnly: self.bluetoothOnly) && $0.isWifiInterface() })
                    if wifiCandidates.count > 0 {
                        chosenAddress = wifiCandidates.first!
                    }
                }
                
                DLog("BluepeerObject inviteBlock: peer has \(hhaddresses.count) addresses, chose \(chosenAddress.addressAndPortString) on interface \(chosenAddress.interfaceName)")
                let sockdata = chosenAddress.socketAsData()
                
                // TODO: when migrating Wifibooth, blueprint: make sure browserFoundPeer calls stopBrowsing()!
                // 1.1: don't stop browsing automatically, delegate must do that now
                //                    self.stopBrowsing() // stop browsing once user has done something. Destroys all HHService except this one!
                
                if let oldSocket = peer.socket {
                    DLog("**** BluepeerObject: PEER ALREADY HAD SOCKET, DESTROYING...")
                    oldSocket.synchronouslySetDelegate(nil)
                    oldSocket.disconnect()
                    peer.socket = nil
                }
                
                peer.socket = GCDAsyncSocket.init(delegate: self, delegateQueue: self.socketQueue)
                peer.socket?.isIPv4PreferredOverIPv6 = false
                peer.state = .connecting
                try peer.socket?.connect(toAddress: sockdata, viaInterface: chosenAddress.interfaceName, withTimeout: 20.0)
            } catch {
                DLog("BluepeerObject: could not connect.")
            }
        }
        
        self.dispatch_on_delegate_queue({
            delegate.browserFoundPeer?(role, peer: peer, customData: (customData.isEmpty ? nil : customData))
        })
    }
    
