gpt4 book ai didi

ios - XMPP 与服务器连接并在 iOS 中配置客户端

转载 作者:行者123 更新时间:2023-11-30 13:27:34 25 4
gpt4 key购买 nike

我正在使用服务器连接到 XMPP 流,但即使用户名、密码错误,连接也始终成功。无法理解为什么会出现这种情况。我想在我的应用程序中配置客户端,并将我的应用程序与 XMPP 服务器连接。帮助将不胜感激。下面是我的代码:

    import UIKit
import XMPPFramework
protocol ChatDelegate {
func buddyWentOnline(name: String)
func buddyWentOffline(name: String)
func didDisconnect()
}
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, XMPPStreamDelegate, XMPPRosterDelegate{
var window: UIWindow?
var delegate:ChatDelegate! = nil
var xmppStream = XMPPStream()
let xmppRosterStorage = XMPPRosterCoreDataStorage()
var xmppRoster: XMPPRoster
override init() {
xmppRoster = XMPPRoster(rosterStorage: xmppRosterStorage)
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions:
[NSObject: AnyObject]?) -> Bool {
//setupStream()
self.xmppStream = XMPPStream()
self.xmppStream.addDelegate(self, delegateQueue: dispatch_get_main_queue())
self.xmppStream.hostName = "****softs-mbp-9"
self.xmppStream.hostPort = 5222
self.connect()
return true
}
func connect() -> Bool {
if !xmppStream.isConnected() {
let jabberID = "admin@****softs-mbp-9"
let myPassword = "**********"

if !xmppStream.isDisconnected() {
return true
}
// if jabberID == nil && myPassword == nil {
// return false
// }

xmppStream.myJID = XMPPJID.jidWithString(jabberID)

do {
try xmppStream.connectWithTimeout(XMPPStreamTimeoutNone)
print("Connection success")
return true
} catch {
print("Something went wrong!")
return false
}
} else {
return true
}
}

func disconnect() {
goOffline()
xmppStream.disconnect()
}
}

最佳答案

您是否将用户名设置为admin@****softs-mbp-9?

关于ios - XMPP 与服务器连接并在 iOS 中配置客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36982859/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com