Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
miramex #1
Member since Feb 2010 · 12 posts
Group memberships: Members
Show profile · Link to this post
Subject: Need help plz !
Hi, I m developping a instant messaging client with c# using the openfire server and the agsxmpp api, I based my work over the sample provided with the agsxmpp package, I could connect to my server and I got the log of the sent message but I m unable to receive it here is the log of the sent message :

<jive xmlns="http://www.jivesoftware.org"><packet xmlns="http://www.jivesoftware.org" streamID="355366fc" status="auth" timestamp="mars 18, 2010 02:44:57:817 PM"><presence xmlns="" from="****@****/agsXMPP"><status/><priority>5</priority></presence></packet><packet xmlns="http://www.jivesoftware.org" streamID="1cb32a2c" status="connected" timestamp="mars 18, 2010 02:45:13:667 PM"><message xmlns="" type="chat" to="****@****"><body>TEST MESSAGE</body></message></packet><packet xmlns="http://www.jivesoftware.org" streamID="1cb32a2c" status="connected" timestamp="mars 18, 2010 02:45:13:683 PM"><message xmlns="" type="error" to="****/1cb32a2c"><body>TEST MESSAGE</body><error code="401" type="auth"><not-authorized



and here is the code where the message should arrive :


using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using agsXMPP;
using agsXMPP.Collections;
using agsXMPP.protocol;
using agsXMPP.protocol.client;


namespace WindowsFormsApplication2.tests
{
    public partial class Test_recep : Form
    {
        public Test_recep()
        {
            InitializeComponent();
        }

        private System.ComponentModel.Container components = null;

        private agsXMPP.XmppClientConnection _connection;
        private Jid                        m_Jid;
        private System.Windows.Forms.StatusBar statusBar1;
        private System.Windows.Forms.PictureBox pictureBox1;
        private System.Windows.Forms.Button cmdSend;
        private System.Windows.Forms.RichTextBox rtfSend;
        private System.Windows.Forms.Splitter splitter1;
        private System.Windows.Forms.RichTextBox rtfChat;
        private string                    _nickname;

       
        public Test_recep(Jid jid, XmppClientConnection con, string nickname)
        {
            m_Jid        = jid;
            _connection = con;
            _nickname    = nickname;
       
           

            InitializeComponent();
           
            this.Text = "Chat with " + nickname;
           
            Util.ChatForms.Add(m_Jid.Bare.ToLower(), this);

           
            con.MessageGrabber.Add(jid, new BareJidComparer(), new MessageCB(MessageCallback), null);
        }

        public Test_recep(Jid jid, XmppClientConnection con, string nickname, bool privateChat)
        {
            m_Jid = jid;
            _connection = con;
            _nickname = nickname;



            InitializeComponent();

            this.Text = "Chat with " + nickname;

            Util.ChatForms.Add(m_Jid.Bare.ToLower(), this);

          
            if (privateChat)
                con.MessageGrabber.Add(jid, new BareJidComparer(), new MessageCB(MessageCallback), null);
            else
                con.MessageGrabber.Add(jid, new FullJidComparer(), new MessageCB(MessageCallback), null);
        }

        public Jid Jid
        {
            get { return m_Jid; }
            set { m_Jid = value; }
        }
       
        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if(components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
           
            Util.ChatForms.Remove(m_Jid.Bare.ToLower());
            _connection.MessageGrabber.Remove(m_Jid);
            _connection = null;
        }

        #region Form-Designer Code
    // the designer code (not important)
        #endregion

        private void OutgoingMessage(agsXMPP.protocol.client.Message msg)
        {
            rtfChat.SelectionColor = Color.Blue;
            rtfChat.AppendText("Me said: ");
            rtfChat.SelectionColor = Color.Black;
            rtfChat.AppendText(msg.Body);
            rtfChat.AppendText("\r\n");
        }

        public void IncomingMessage(agsXMPP.protocol.client.Message msg)
        {
            rtfChat.SelectionColor = Color.Red;
            rtfChat.AppendText(_nickname + " said: ");
            rtfChat.SelectionColor = Color.Black;
            rtfChat.AppendText(msg.Body);
            rtfChat.AppendText("\r\n");
        }

        private void cmdSend_Click(object sender, System.EventArgs e)
        {
            agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();

            msg.Type    = MessageType.chat;
            msg.To        = m_Jid;
            msg.Body    = rtfSend.Text;
           
            _connection.Send(msg);
            OutgoingMessage(msg);
            rtfSend.Text = "";
        }

        private void MessageCallback(object sender, agsXMPP.protocol.client.Message msg, object data)
        {
            if (InvokeRequired)
            {
                           
                BeginInvoke(new MessageCB(MessageCallback), new object[] { sender, msg, data });
                return;
            }
           
            if (msg.Body != null)
                IncomingMessage(msg);
        }
    }
}

I m unable to find where is the problem moreover if its clear in the xml
This post was edited on 2010-03-18, 12:43 by miramex.
Avatar
miramex #2
Member since Feb 2010 · 12 posts
Group memberships: Members
Show profile · Link to this post
alex do you have any idea about this?
Avatar
Alex #3
Member since Feb 2003 · 4307 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
the log from agsXMPP would be better than the Openfire log. But according to the log you are not authorized to send the message to the other user.
Are you subscribed to the other user?

Alex
Avatar
miramex #4
Member since Feb 2010 · 12 posts
Group memberships: Members
Show profile · Link to this post
where could I get the ags log ? do you mean by "subscribed" if that the users are boddies of each other ?
Avatar
Alex #5
Member since Feb 2003 · 4307 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by miramex:
where could I get the ags log ?
from the OnReadXml and OnWriteXml handlers.

Quote by miramex:
do you mean by "subscribed" if that the users are boddies of each other ?
yes, and if the subscription property is both on both contact lists.

Alex
Avatar
miramex #6
Member since Feb 2010 · 12 posts
Group memberships: Members
Show profile · Link to this post
no the users are not in each others budy list and I really have no idea about how raising up the event for the Onreadxml handler neither on how to get the report back :( I m really sorry for getting it harder to help me
Avatar
Alex #7
Member since Feb 2003 · 4307 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
This is all described in the examples. Please study our examples, especially the MiniClient example.
If the contacts are not in each others contact list then this is your problem. Many servers block messages from users not in your list to prevent SPAM.

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: agsXMPP RSS