-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Hi,
I have this running on 2 physical devices but when I try to connect them, I simply get this in the Xcode cmd output:
Not in connected state, so giving up for participant [48c78cc] on channel [0]. Not in connected state, so giving up for participant [48c78cc] on channel [1]. Not in connected state, so giving up for participant [48c78cc] on channel [2].
The peers never connect to each other. Is there anything I need to consider aside from initializing the session? I am currently doing it like in the sample app (which works fine on both devices)
import Foundation
import SwiftUI
import Foundation
import MultipeerConnectivity
struct tutorialView: View {
@State var delegate = multidelegate()
var body: some View {
Text("Peers connected: \(delegate.multipeerHelp?.connectedPeers.count ?? 999)").onAppear(){
delegate.setupMultipeer()
}
}
}
class multidelegate: MultipeerHelperDelegate{
var multipeerHelp: MultipeerHelper!
func setupMultipeer() {
multipeerHelp = MultipeerHelper(
serviceName: "demo",
sessionType: .both,
delegate: self
)
}
func receivedData(_ data: Data, _ peer: MCPeerID) {
print(String(data: data, encoding: .unicode) ?? "Data is not a unicode string")
}
func peerJoined(_ peer: MCPeerID) {
print("new peer has joined: \(peer.displayName)")
}
}
Metadata
Metadata
Assignees
Labels
No labels