 import UIKit
 
 public protocol SplooshSearchDelegate: class {
-    func foundPeersChanged(foundPeers: [String])
-    
-    func invitationReceived(peer: String, handleInvitation: (Bool) -> Void)
-    
-    func connectedPeersChanged(peers: [String])
+    func foundHostsChanged(foundHosts: [MCPeerID])
+    
+    func invitationToConnectReceived(peer: MCPeerID, handleInvitation: (Bool) -> Void)
+    
+    func connectionsChanged(peers: [MCPeerID])
+    
+    func connectedToPeer(peer: MCPeerID)
+    
+    func handleDataPacket(data: NSData, peerID: MCPeerID)
 }
 
 public class SplooshSearch: NSObject {
+    var autoAcceptGuests = true
+    
+    static let defaultTimeout: NSTimeInterval = 30
     private var serviceAdvertiser: MCNearbyServiceAdvertiser?
     private var serviceBrowser: MCNearbyServiceBrowser?
-    private var isSearching = false
-    private var foundPeers = [String]()
+    private var foundHosts = [MCPeerID]()
     
     public weak var delegate: SplooshSearchDelegate?
     

    // Peer is found in browser
    public func browser(browser: MCNearbyServiceBrowser, foundPeer peerID: MCPeerID,
        withDiscoveryInfo info: [String : String]?) {
            foundPeers.append(peerID.displayName)
            delegate?.foundPeersChanged(foundPeers)
    }
    
    // Peer is lost in browser
    public func browser(browser: MCNearbyServiceBrowser, lostPeer peerID: MCPeerID) {
        if let index = foundPeers.indexOf(peerID.displayName) {
            foundPeers.removeAtIndex(index)
            delegate?.foundPeersChanged(foundPeers)
        }
    }
}


        fromPeer peerID: MCPeerID, withProgress progress: NSProgress) {
            
    }
}

extension MCSessionState {
    func stringValue() -> String {
        switch(self) {
        case .NotConnected: return "NotConnected"
        case .Connecting: return "Connecting"
        case .Connected: return "Connected"
        }
    }
}