Using this code to setup Multipeer connectivity under TViOS 10.0.
import UIKit
import MultipeerConnectivity
class MPCHandler: NSObject, MCSessionDelegate {
var peerID: MCPeerID!
var session: MCSession!
var browser: MCBrowserViewController!
var advertiser: MCAdvertiserAssistant? = nil
func setupPeerWithDisplayName (displayName: String) {
peerID = MCPeerID(displayName: UIDevice.current.name)
}
func setupSession() {
session = MCSession(peer: peerID)
session.delegate = self
}
func setupBrowser() {
browser = MCBrowserViewController(serviceType: "my-game", session: session)
}
func advertiseSelf(advertise:Bool) {
if advertise {
advertiser = MCAdvertiserAssistant(serviceType: "my-game", discoveryInfo: nil, session: session)
advertiser!.start()
} else {
advertiser!.stop()
advertiser = nil
}
}
public class MyClass {
static let myNotification = Notification.Name("MPC_DidChangeStateNotification")
}
public class MyClass2 {
static let myNotification = Notification.Name("MPC_DidRecieveDataNotification")
}
func session(_ session: MCSession, peer peerID: MCPeerID, didChange state: MCSessionState) {
let userInfo = ["peerID":peerID,"state":state.rawValue] as [String : Any]
DispatchQueue.main.async {
NotificationCenter.default.post(name: MyClass.myNotification, object: nil, userInfo: userInfo)
}
}
func session(_ session: MCSession, didReceive data: Data, fromPeer peerID: MCPeerID) {
let userInfo = ["data":data, "peerID":peerID] as [String : Any]
DispatchQueue.main.async {
NotificationCenter.default.post(name: MyClass2.myNotification, object: nil, userInfo: userInfo)
}
}
func session(_ session: MCSession, didFinishReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, at localURL: URL, withError error: Error?) {
// code
}
func session(_ session: MCSession, didStartReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, with progress: Progress) {
// code
}
func session(_ session: MCSession, didReceive stream: InputStream, withName streamName: String, fromPeer peerID: MCPeerID) {
// code
}
}
Reports connected, but I get this errors? Both devices TViOS and iPhone on the same network.
2016-09-08 11:13:13.602572 PeerCodeATV[172:7628] [ViceroyTrace] [ICE][ERROR] ICEStopConnectivityCheck() found no ICE check with call id (1969443468)
2016-09-08 11:13:17.168110 PeerCodeATV[172:7686] [ViceroyTrace] [ICE][ERROR] Send BINDING_REQUEST failed(C01A0041).
2016-09-08 11:13:18.044156 PeerCodeATV[172:7686] [ViceroyTrace] [ICE][ERROR] Send BINDING_REQUEST failed(C01A0041).
2016-09-08 11:13:18.766040 PeerCodeATV[172:7686] [ViceroyTrace] [ICE][ERROR] Send BINDING_REQUEST failed(C01A0041).
2016-09-08 11:13:20.015846 PeerCodeATV[172:7686] [ViceroyTrace] [ICE][ERROR]
2016-09-08 11:13:24.453030 PeerCodeATV[172:7588] [GCKSession] Not in connected state, so giving up for participant [7563528C] on channel [0].
2016-09-08 11:13:24.476176 PeerCodeATV[172:7588] [GCKSession] Not in connected state, so giving up for participant [7563528C] on channel [1].
2016-09-08 11:13:24.498394 PeerCodeATV[172:7588] [ViceroyTrace] [ICE][ERROR] ICEStopConnectivityCheck() found no ICE check with call id (1969443468)
2016-09-08 11:13:24.498840 PeerCodeATV[172:7588] [GCKSession] Not in connected state, so giving up for participant [7563528C] on channel [2].
2016-09-08 11:13:24.522667 PeerCodeATV[172:7588] [ViceroyTrace] [ICE][ERROR] ICEStopConnectivityCheck() found no ICE check with call id (1969443468)
2016-09-08 11:13:24.522954 PeerCodeATV[172:7588] [GCKSession] Not in connected state, so giving up for participant [7563528C] on channel [3].
2016-09-08 11:13:24.545934 PeerCodeATV[172:7588] [ViceroyTrace] [ICE][ERROR] ICEStopConnectivityCheck() found no ICE check with call id (1969443468)
I already tested the code iOS to iOS, it works perfectly across the same iOS, but iPad running iOS 9.2 -> TViOS 10.0 I see these errors?
It works if I reboot the AppleTV with these errors, subsequent connections however fail!!
_mpcSession = [[MCSession alloc] initWithPeer:self.mpcPeerID];
i used:_mpcSession = [[MCSession alloc] initWithPeer:self.mpcPeerID securityIdentity:nil encryptionPreference:MCEncryptionNone];
– Lumbricalis