【发布时间】:2020-08-10 10:45:05
【问题描述】:
在viewDidLoad 我设置了我的会话:
peerID = MCPeerID(displayName: UIDevice.current.name)
mcSession = MCSession(peer: peerID, securityIdentity: nil, encryptionPreference: .required)
mcSession.delegate = self
mcAdvertiserAssistant = MCAdvertiserAssistant(serviceType: "hws-kb", discoveryInfo: nil, session: mcSession)
并有四个动作:
func startHosting() {
mcAdvertiserAssistant.start() //run the session
}
func endHosting() {
mcAdvertiserAssistant.stop() //stop the session
}
func joinSession() {
let mcBrowser = MCBrowserViewController(serviceType: "hws-kb", session: mcSession)
mcBrowser.delegate = self
present(mcBrowser, animated: true) //join me to active session
}
func leaveSession() {
mcSession.disconnect() //leave me from active session
}
//how do Invite others to my session?
以上方式我所能控制的就是当有人想连接时接受或拒绝。但是我想亲自向用户发送邀请,并且不允许其他人在没有我邀请的情况下加入。有可能吗?
【问题讨论】:
标签: ios swift multipeer-connectivity