Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
CyrilleTelmer #1
Member since Sep 2011 · 1 post
Group memberships: Members
Show profile · Link to this post
Subject: nullreferenceexception with subscribe
Hello.
I am trying to do a xmpp client with matrix, and i have problem with subscription.
I want the user to be able to invite people, and chat with them. But the invitation part does not work. for example, i have:

        public XmppClient xmpp;
        public PresenceManager pm;


   public ClientConstructor(string JabberID, string password, string status)
        {
            senderJIDM = JabberID;
            pass = password;
            senderJIDM = new Jid(JabberID);
            xmpp = new XmppClient();
            xmpp.SetUsername(senderJIDM.User);
            xmpp.SetXmppDomain(senderJIDM.Server);
            xmpp.Status = status;
            xmpp.Password = password;
            xmpp.Show = Matrix.Xmpp.Show.chat;
            // Trying to connect...
            try
            {
                xmpp.Open();           
            }
            catch
            {
                MessageBox.Show("Wrong login data!");
            }
            xmpp.AutoRoster = true;
            xmpp.OnRosterItem += new EventHandler<Matrix.Xmpp.Roster.RosterEventArgs>(xmpp_OnItem);
            xmpp.OnAuthError += new EventHandler<Matrix.Xmpp.Sasl.SaslEventArgs>(xmpp_OnAuthError);
            xmpp.OnRosterEnd += new EventHandler<Matrix.EventArgs>(xmpp_OnEnd);
            xmpp.OnError += new EventHandler<Matrix.ExceptionEventArgs>(xmppClient_OnError);
            xmpp.OnIq += new EventHandler<IqEventArgs>(xmppClient_OnIq);
            xmpp.OnPresence += new EventHandler<PresenceEventArgs>(xmpp_OnPresence);
            xmpp.OnMessage += new EventHandler<MessageEventArgs>(xmpp_OnMessage);
            xmpp.OnBind += new System.EventHandler<JidEventArgs>(xmppClient_OnBind);

            pm = new PresenceManager(xmpp);
            pm.OnSubscribe += new EventHandler<PresenceEventArgs>(presenceManager_OnSubscribe);
        }

public void suscribeToThisSite(string user)
        {
            Jid jid = user + "@gmail.com";
            pm.Subscribe(jid);
        }

And so, whenever i call suscribeToThisSite(string user), i have the xmpp.OnError event raised, the exception message being something like:  nullreferenceexception, at Matrix.Net.ClientSocket.Send(Byte[] bData)

What do you think causes this error?
This post was edited on 2011-09-17, 19:59 by CyrilleTelmer.
Avatar
Alex #2
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by CyrilleTelmer:
And so, whenever i call suscribeToThisSite(string user), i have the xmpp.OnError event raised, the exception message being something like:  nullreferenceexception, at Matrix.Net.ClientSocket.Send(Byte[] bData)

What do you think causes this error?

can you post the full stacktrace and see if you get a OnClose before you send the subscribe?

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS