我使用了xmppframewotk ios。连接委托不在swift 3中工作。但socket已连接。
答案 0 :(得分:0)
import XMPPFramework
inherited XMPPRosterDelegate,XMPPStreamDelegate
var xmppStream:XMPPStream
! let xmppRosterStorage = XMPPRosterCoreDataStorage()
var xmppRoster: XMPPRoster
<!/ LI>
醇>
代码:
func connect() -> Bool {
if xmppStream == nil {
xmppStream = XMPPStream()
xmppStream.addDelegate(self, delegateQueue: DispatchQueue.main)
}
if xmppStream.isDisconnected(){
if !(xmppStream?.isDisconnected())! {
return true
}
xmppStream?.myJID = XMPPJID.init(string: JABBERID)
xmppStream?.hostName = aHost
xmppStream?.hostPort = 5222
xmppStream?.enableBackgroundingOnSocket = true
do {
try xmppStream?.connect(withTimeout: XMPPStreamTimeoutNone)
print("Connection success")
return true
} catch {
print("Something went wrong!")
return false
}
} else {
return true
}
}