【发布时间】:2015-01-25 02:12:40
【问题描述】:
我正在尝试使用 swift 使用 XMPP 框架(https://github.com/robbiehanson/XMPPFramework)。 我是 swift 新手
class ViewController: UIViewController {
var password: NSString?
var isOpen: Bool = false
var xstream: XMPPStream?
var loginServer: String = ""
override func viewDidLoad() {
super.viewDidLoad()
println(connect())
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func connect() ->Bool{
var xstream = XMPPStream()
var error: NSError?
xstream.addDelegate(self, delegateQueue: dispatch_get_main_queue())
xstream.myJID = XMPPJID.jidWithString("test@localhost")
xstream.hostName="127.0.0.1"
xstream.hostPort=5222
var password = "testing"
if !xstream.connectWithTimeout(XMPPStreamTimeoutNone, error: &error) {
println(error)
}
println(xstream.isConnecting()) // This prints true
return xstream.isConnected();// This prints false.
}
}
用户名和密码以及服务器详细信息是正确的,因为我使用 adium 连接到服务器并且它工作正常。
【问题讨论】:
-
我也有同样的问题。你有什么解决办法吗?
标签: ios swift xmppframework