简体   繁体   English

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

[英]XMPP Connection with server and configure Client side in iOS

I am connecting to the XMPP stream with server but the connection is always successful even if username, password is wrong. 我正在使用服务器连接到XMPP流,但是即使用户名,密码错误,连接也总是成功的。 Can't understand why this occurs. 无法理解为什么会这样。 I want to configure client side in my app and want to connect my app with the XMPP server. 我想在我的应用程序中配置客户端,并想将我的应用程序与XMPP服务器连接。 Help will be appreciated. 帮助将不胜感激。 Below is my code: 下面是我的代码:

    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?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM