0

我正在开发 c# 客户端来连接 Openfire 服务器

这是我的代码

        User = txtUserName.Text;
        Pwd = txtPassword.Text;
        pnlCredentials.Enabled = false;
        jabberClient1.User = User;
        jabberClient1.Server = "61.182.225.189";
        jabberClient1.Password = Pwd;
        jabberClient1.AutoRoster = true;

        jabberClient1.Port = 5222;

        JID jid = new JID("kamal", "192,168,1,17", "123456");



        jabberClient1.AutoLogin = true;
        jabberClient1.Resource = jid.Resource;

        jabberClient1.AutoStartTLS = true;
        jabberClient1.NetworkHost = null;
        jabberClient1.OnInvalidCertificate += new System.Net.Security.RemoteCertificateValidationCallback(jabberClient1_OnInvalidCertificate);

        rm = new RosterManager();
        rm.Stream = jabberClient1;
        rm.AutoSubscribe = true;
        rm.AutoAllow = jabber.client.AutoSubscriptionHanding.AllowAll;
        rm.OnRosterBegin += new bedrock.ObjectHandler(rm_OnRosterBegin);
        rm.OnRosterEnd += new bedrock.ObjectHandler(rm_OnRosterEnd);
        rm.OnRosterItem += new RosterItemHandler(rm_OnRosterItem);


        pm = new PresenceManager();
        pm.Stream = jabberClient1;

        rosterTree1.RosterManager = rm;
        rosterTree1.PresenceManager = pm;
        rosterTree1.DoubleClick += new EventHandler(rosterTree1_DoubleClick);
        jabberClient1.OnAuthenticate += new bedrock.ObjectHandler(jabberClient1_OnAuthenticate);
        lblUser.Text = jabberClient1.User;

        jabberClient1.Connect();

我不确定我需要在下面的参数中使用什么

JID jid = new JID("kamal", "192,168,1,17", "123456");

我为此使用了用户名、服务器 IP 和密码

当我运行它时它返回错误

错误绑定资源 error type="modify" code="400"bad-requestmlns="urn:ietf:params:xml:ns:xmpp-stanzas"

你能帮我解决这个问题吗

先感谢您

我已经使用最新的 Jabber.net DLL 编辑了代码,如下所示

        JabberClient jabberClient = new JabberClient();

        //Bind the JabberClient events to methods that handle those events.
        jabberClient.OnAuthError += new IQHandler(jabberClient_OnAuthError);

        jabberClient.OnError += new bedrock.ExceptionHandler(jabberClient_OnError);
        jabberClient.OnConnect += new bedrock.ObjectHandler(jabberClient_OnConnect);
        jabberClient.OnDisconnect += new bedrock.ObjectHandler(jabberClient_OnDisconnect);

        //Set client settings
        jabberClient.AutoReconnect = 3;

        JID jid = new JID("kamal", "192.168,1,17", "123456");
        jabberClient.User = jid.User;

        jabberClient.Server = jid.Server;


        jabberClient.Port =5222;
        jabberClient.Resource = jid.Resource;
        jabberClient.Password = "123456";

        jabberClient.AutoPresence = false;
        jabberClient.AutoLogin = true;





        jabberClient.Connect();

现在,当我尝试连接时,它会触发断开事件吗?

4

0 回答 0